ZQuest Classic Coverage Report


Directory: src/
File: src/base/qst.cpp
Date: 2025-07-14 06:41:52
Exec Total Coverage
Lines: 9348 12914 72.4%
Functions: 111 141 78.7%
Branches: 7054 12011 58.7%

Line Branch Exec Source
1 #include "allegro/file.h"
2 #include "base/flags.h"
3 #include "base/general.h"
4 #include "base/util.h"
5 #include "base/version.h"
6 #include "base/zapp.h"
7 #include "base/qrs.h"
8 #include "base/cpool.h"
9 #include "base/autocombo.h"
10 #include "base/packfile.h"
11 #include "base/dmap.h"
12 #include "base/combo.h"
13 #include "base/msgstr.h"
14 #include "base/flags.h"
15 #include <bit>
16 #include <filesystem>
17 #include <memory>
18 #include <optional>
19 #include <stdio.h>
20 #include <cstring>
21 #include <string>
22 #include <map>
23 #include <vector>
24 #include <assert.h>
25 #include <fmt/format.h>
26
27
28 #include "fmt/core.h"
29 #include "base/zc_alleg.h"
30 #include "base/zdefs.h"
31 #include "base/colors.h"
32 #include "tiles.h"
33 #include "base/zsys.h"
34 #include "base/qst.h"
35 #include "defdata.h"
36 #include "subscr.h"
37 #include "sfx.h"
38 #include "base/md5.h"
39 #include "zc/replay.h"
40 #include "zc/zelda.h"
41 #include "zinfo.h"
42 #include "zc/ffscript.h"
43 #include "particles.h"
44 #include "dialog/alert.h"
45 #include "base/misctypes.h"
46 #include "base/initdata.h"
47
48 extern sprite_list guys, items, Ewpns, Lwpns, chainlinks, decorations;
49 extern void setZScriptVersion(int32_t s_version);
50
51 static bool read_ext_zinfo = false, read_zinfo = false;
52 static bool loadquest_report = false;
53 static char const* loading_qst_name = NULL;
54 static std::string last_loaded_qstpath;
55 static byte loading_qst_num = 0;
56 static byte subscr_mode = ssdtMAX;
57 // Very old quests only used a byte for combos, and each screen had a "combo page" to vary
58 // what combos were used. This vector just lets us convert those old quests on load.
59 static std::vector<byte> old_combo_pages;
60
61 dword loading_tileset_flags = 0;
62
63 int32_t First[MAX_COMBO_COLS]={0},combo_alistpos[MAX_COMBO_COLS]={0},combo_pool_listpos[MAX_COMBO_COLS]={0},combo_auto_listpos[MAX_COMBO_COLS]={0};
64 map_and_screen map_page[MAX_MAPPAGE_BTNS]= {{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}};
65
66 #ifdef _MSC_VER
67 #define strncasecmp _strnicmp
68 #endif
69
70 #ifndef _AL_MALLOC
71 #define _AL_MALLOC(a) _al_malloc(a)
72 #define _AL_FREE(a) _al_free(a)
73 #endif
74
75 using std::string;
76 using std::pair;
77
78 extern int32_t hero_animation_speed; //lower is faster animation
79 extern byte *colordata;
80 extern tiledata *newtilebuf;
81 extern byte *trashbuf;
82 extern itemdata *itemsbuf;
83 extern wpndata *wpnsbuf;
84 extern comboclass *combo_class_buf;
85 extern guydata *guysbuf;
86 extern ZCHEATS zcheats;
87 extern char palnames[MAXLEVELS][17];
88 extern char *byte_conversion(int32_t number, int32_t format);
89 extern char *byte_conversion2(int32_t number1, int32_t number2, int32_t format1, int32_t format2);
90 string zScript;
91 421 std::map<int32_t, script_slot_data > ffcmap;
92 421 std::map<int32_t, script_slot_data > globalmap;
93 421 std::map<int32_t, script_slot_data > genericmap;
94 421 std::map<int32_t, script_slot_data > itemmap;
95 421 std::map<int32_t, script_slot_data > npcmap;
96 421 std::map<int32_t, script_slot_data > ewpnmap;
97 421 std::map<int32_t, script_slot_data > lwpnmap;
98 421 std::map<int32_t, script_slot_data > playermap;
99 421 std::map<int32_t, script_slot_data > dmapmap;
100 421 std::map<int32_t, script_slot_data > screenmap;
101 421 std::map<int32_t, script_slot_data > itemspritemap;
102 421 std::map<int32_t, script_slot_data > comboscriptmap;
103 421 std::map<int32_t, script_slot_data > subscreenmap;
104 void free_newtilebuf();
105 bool combosread=false;
106 bool mapsread=false;
107 bool fixffcs=false;
108 bool fixpolsvoice=false;
109
110 // Each section had a separate, secondary versioning number, but it was never really utilized for
111 // its intended purpose so it's been removed. But we still write something in this field.
112 232 bool write_deprecated_section_cversion(word section_version, PACKFILE* f)
113 {
114 232 return p_iputw(section_version, f);
115 }
116
117 14461 bool read_deprecated_section_cversion(PACKFILE* f)
118 {
119 word unused;
120 14461 return p_igetw(&unused, f);
121 }
122
123 21993 void script_slot_data::update()
124 {
125
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 21987 times.
21993 switch (format)
126 {
127 case SCRIPT_FORMAT_INVALID:
128 6 output = fmt::format("{} --{}", slotname, scriptname);
129 6 break;
130 21987 case SCRIPT_FORMAT_DEFAULT:
131 default:
132 21987 output = fmt::format("{} {}", slotname, scriptname);
133 21987 }
134 21993 }
135
136 char qstdat_string[2048] = { 0 };
137
138 static zinfo* load_tmp_zi = NULL;
139
140 int32_t memDBGwatch[8]= {0,0,0,0,0,0,0,0}; //So I can monitor memory crap
141 const byte clavio[9]={97,109,111,110,103,117,115,0};
142
143 //enum { qe_OK, qe_notfound, qe_invalid, qe_version, qe_obsolete,
144 // qe_missing, qe_internal, qe_pwd, qe_match, qe_minver };
145
146 const char *qst_error[] =
147 {
148 "OK","File not found","Invalid quest file",
149 "Version not supported","Obsolete version",
150 "Missing new data" , /* but let it pass in ZQuest */
151 "Internal error occurred", "Invalid password",
152 "Quest title doesn't match saved game", "Save file is for older version of quest; please start new save",
153 "Out of memory", "File Debug Mode", "Canceled", "", "No quest assigned"
154 };
155
156 //for legacy quests -DD
157 enum { ssiBOMB, ssiSWORD, ssiSHIELD, ssiCANDLE, ssiLETTER, ssiPOTION, ssiLETTERPOTION, ssiBOW, ssiARROW, ssiBOWANDARROW, ssiBAIT, ssiRING, ssiBRACELET, ssiMAP,
158 ssiCOMPASS, ssiBOSSKEY, ssiMAGICKEY, ssiBRANG, ssiWAND, ssiRAFT, ssiLADDER, ssiWHISTLE, ssiBOOK, ssiWALLET, ssiSBOMB, ssiHCPIECE, ssiAMULET, ssiFLIPPERS,
159 ssiHOOKSHOT, ssiLENS, ssiHAMMER, ssiBOOTS, ssiDIVINEFIRE, ssiDIVINEESCAPE, ssiDIVINEPROTECTION, ssiQUIVER, ssiBOMBBAG, ssiCBYRNA, ssiROCS, ssiHOVERBOOTS,
160 ssiSPINSCROLL, ssiCROSSSCROLL, ssiQUAKESCROLL, ssiWHISPRING, ssiCHARGERING, ssiPERILSCROLL, ssiWEALTHMEDAL, ssiHEARTRING, ssiMAGICRING, ssiSPINSCROLL2,
161 ssiQUAKESCROLL2, ssiAGONY, ssiSTOMPBOOTS, ssiWHIMSICALRING, ssiPERILRING, ssiMAX
162 };
163
164 static byte deprecated_rules[QUESTRULES_NEW_SIZE];
165
166
167 char *byte_conversion(int32_t number, int32_t format)
168 {
169 static char num_str[40];
170
171 if(format==-1) //auto
172 {
173 format=1; //bytes
174
175 if(number>1024)
176 {
177 format=2; //kilobytes
178 }
179
180 if(number>1024*1024)
181 {
182 format=3; //megabytes
183 }
184
185 if(number>1024*1024*1024)
186 {
187 format=4; //gigabytes (dude, what are you doing?)
188 }
189 }
190
191 switch(format)
192 {
193 case 1: //bytes
194 sprintf(num_str,"%db",number);
195 break;
196
197 case 2: //kilobytes
198 sprintf(num_str,"%.2fk",float(number)/1024);
199 break;
200
201 case 3: //megabytes
202 sprintf(num_str,"%.2fM",float(number)/(1024*1024));
203 break;
204
205 case 4: //gigabytes
206 sprintf(num_str,"%.2fG",float(number)/(1024*1024*1024));
207 break;
208
209 default:
210 abort();
211 break;
212 }
213
214 return num_str;
215 }
216
217 char *byte_conversion2(int32_t number1, int32_t number2, int32_t format1, int32_t format2)
218 {
219 static char num_str1[40];
220 static char num_str2[40];
221 static char num_str[80];
222
223 if(format1==-1) //auto
224 {
225 format1=1; //bytes
226
227 if(number1>1024)
228 {
229 format1=2; //kilobytes
230 }
231
232 if(number1>1024*1024)
233 {
234 format1=3; //megabytes
235 }
236
237 if(number1>1024*1024*1024)
238 {
239 format1=4; //gigabytes (dude, what are you doing?)
240 }
241 }
242
243 if(format2==-1) //auto
244 {
245 format2=1; //bytes
246
247 if(number2>1024)
248 {
249 format2=2; //kilobytes
250 }
251
252 if(number2>1024*1024)
253 {
254 format2=3; //megabytes
255 }
256
257 if(number2>1024*1024*1024)
258 {
259 format2=4; //gigabytes (dude, what are you doing?)
260 }
261 }
262
263 switch(format1)
264 {
265 case 1: //bytes
266 sprintf(num_str1,"%db",number1);
267 break;
268
269 case 2: //kilobytes
270 sprintf(num_str1,"%.2fk",float(number1)/1024);
271 break;
272
273 case 3: //megabytes
274 sprintf(num_str1,"%.2fM",float(number1)/(1024*1024));
275 break;
276
277 case 4: //gigabytes
278 sprintf(num_str1,"%.2fG",float(number1)/(1024*1024*1024));
279 break;
280
281 default:
282 abort();
283 break;
284 }
285
286 switch(format2)
287 {
288 case 1: //bytes
289 sprintf(num_str2,"%db",number2);
290 break;
291
292 case 2: //kilobytes
293 sprintf(num_str2,"%.2fk",float(number2)/1024);
294 break;
295
296 case 3: //megabytes
297 sprintf(num_str2,"%.2fM",float(number2)/(1024*1024));
298 break;
299
300 case 4: //gigabytes
301 sprintf(num_str2,"%.2fG",float(number2)/(1024*1024*1024));
302 break;
303
304 default:
305 abort();
306 break;
307 }
308
309 sprintf(num_str, "%s/%s", num_str1, num_str2);
310 return num_str;
311 }
312
313 char *ordinal(int32_t num)
314 {
315 static const char *ending[4] = {"st","nd","rd","th"};
316 static char ord_str[8];
317
318 char *end;
319 int32_t t=(num%100)/10;
320 int32_t n=num%10;
321
322 if(n>=1 && n<4 && t!=1)
323 end = (char *)ending[n-1];
324 else
325 end = (char *)ending[3];
326
327 sprintf(ord_str,"%d%s",num%10000,end);
328 return ord_str;
329 }
330
331 int32_t get_version_and_build(PACKFILE *f, word *version, word *build)
332 {
333 int32_t ret;
334 *version=0;
335 *build=0;
336 byte temp_map_count=map_count;
337 byte temp_midi_flags[MIDIFLAGS_SIZE];
338 memcpy(temp_midi_flags, midi_flags, MIDIFLAGS_SIZE);
339
340 zquestheader tempheader{};
341
342 if(!f)
343 {
344 return qe_invalid;
345 }
346
347 ret=readheader(f, &tempheader);
348
349 if(ret)
350 {
351 return ret;
352 }
353
354 map_count=temp_map_count;
355 memcpy(midi_flags, temp_midi_flags, MIDIFLAGS_SIZE);
356 *version=tempheader.zelda_version;
357 *build=tempheader.build;
358 return 0;
359 }
360
361
362 bool find_section(PACKFILE *f, int32_t section_id_requested)
363 {
364
365 if(!f)
366 {
367 return false;
368 }
369
370 int32_t section_id_read;
371 bool catchup=false;
372 word dummy;
373 byte tempbyte;
374 char tempbuf[65536];
375
376
377 switch(section_id_requested)
378 {
379 case ID_RULES:
380 case ID_STRINGS:
381 case ID_MISC:
382 case ID_TILES:
383 case ID_COMBOS:
384 case ID_CSETS:
385 case ID_MAPS:
386 case ID_DMAPS:
387 case ID_DOORS:
388 case ID_ITEMS:
389 case ID_WEAPONS:
390 case ID_COLORS:
391 case ID_ICONS:
392 case ID_INITDATA:
393 case ID_GUYS:
394 case ID_MIDIS:
395 case ID_CHEATS:
396 break;
397
398 default:
399 al_trace("Bad section requested!\n");
400 return false;
401 break;
402 }
403
404 dword section_size;
405
406 //section id
407 if(!p_mgetl(&section_id_read,f))
408 {
409 return false;
410 }
411
412 while(!pack_feof(f))
413 {
414 switch(section_id_read)
415 {
416 case ID_RULES:
417 case ID_STRINGS:
418 case ID_MISC:
419 case ID_TILES:
420 case ID_COMBOS:
421 case ID_CSETS:
422 case ID_MAPS:
423 case ID_DMAPS:
424 case ID_DOORS:
425 case ID_ITEMS:
426 case ID_WEAPONS:
427 case ID_COLORS:
428 case ID_ICONS:
429 case ID_INITDATA:
430 case ID_GUYS:
431 case ID_MIDIS:
432 case ID_CHEATS:
433 catchup=false;
434 break;
435
436 default:
437 break;
438 }
439
440
441 while(catchup)
442 {
443 //section id
444 section_id_read=(section_id_read<<8);
445
446 if(!p_getc(&tempbyte,f))
447 {
448 return false;
449 }
450
451 section_id_read+=tempbyte;
452 }
453
454 if(section_id_read==section_id_requested)
455 {
456 return true;
457 }
458 else
459 {
460 //section version info
461 if(!p_igetw(&dummy,f))
462 {
463 return false;
464 }
465
466 if(!p_igetw(&dummy,f))
467 {
468 return false;
469 }
470
471 //section size
472 if(!p_igetl(&section_size,f))
473 {
474 return false;
475 }
476
477 //pack_fseek(f, section_size);
478 while(section_size>65535)
479 {
480 pfread(tempbuf,65535,f);
481 tempbuf[65535]=0;
482 section_size-=65535;
483 }
484
485 if(section_size>0)
486 {
487 pfread(tempbuf,section_size,f);
488 tempbuf[section_size]=0;
489 }
490 }
491
492 //section id
493 if(!p_mgetl(&section_id_read,f))
494 {
495 return false;
496 }
497 }
498
499 return false;
500 }
501
502
503
504
505
506 bool valid_zqt(PACKFILE *f)
507 {
508
509 //word tiles_used;
510 //word combos_used;
511 //open the file
512 //PACKFILE *f = pack_fopen(path, F_READ_PACKED);
513 if(!f)
514 return false;
515
516 //for now, everything else is valid
517 return true;
518
519 /*int16_t version;
520 byte build;
521
522 //read the version and make sure it worked
523 if(!p_igetw(&version,f))
524 {
525 goto error;
526 }
527
528 //read the build and make sure it worked
529 if(!p_getc(&build,f))
530 goto error;
531
532 //read the tile info and make sure it worked
533 if(!p_igetw(&tiles_used,f))
534 {
535 goto error;
536 }
537
538 for (int32_t i=0; i<tiles_used; i++)
539 {
540 if(!pfread(trashbuf,tilesize(tf4Bit),f))
541 {
542 goto error;
543 }
544 }
545
546 //read the combo info and make sure it worked
547 if(!p_igetw(&combos_used,f))
548 {
549 goto error;
550 }
551 for (int32_t i=0; i<combos_used; i++)
552 {
553 if(!pfread(trashbuf,sizeof(newcombo),f))
554 {
555 goto error;
556 }
557 }
558
559 //read the palette info and make sure it worked
560 for (int32_t i=0; i<48; i++)
561 {
562 if(!pfread(trashbuf,newpdTOTAL,f))
563 {
564 goto error;
565 }
566 }
567 if(!pfread(trashbuf,sizeof(palcycle)*256*3,f))
568 {
569 goto error;
570 }
571 for (int32_t i=0; i<MAXLEVELS; i++)
572 {
573 if(!pfread(trashbuf,PALNAMESIZE,f))
574 {
575 goto error;
576 }
577 }
578
579 //read the sprite info and make sure it worked
580 for (int32_t i=0; i<MAXITEMS; i++)
581 {
582 if(!pfread(trashbuf,sizeof(itemdata),f))
583 {
584 goto error;
585 }
586 }
587
588 for (int32_t i=0; i<MAXWPNS; i++)
589 {
590 if(!pfread(trashbuf,sizeof(wpndata),f))
591 {
592 goto error;
593 }
594 }
595
596 //read the triforce pieces info and make sure it worked
597 for (int32_t i=0; i<8; ++i)
598 {
599 if(!p_getc(&trashbuf,f))
600 {
601 goto error;
602 }
603 }
604
605
606
607 //read the game icons info and make sure it worked
608 for (int32_t i=0; i<4; ++i)
609 {
610 if(!p_igetw(&trashbuf,f))
611 {
612 goto error;
613 }
614 }
615
616 //read the misc colors info and map styles info and make sure it worked
617 if(!pfread(trashbuf,sizeof(zcolors),f))
618 {
619 goto error;
620 }
621
622 //read the template screens and make sure it worked
623 byte num_maps;
624 if(!p_getc(&num_maps,f))
625 {
626 goto error;
627 }
628 for (int32_t i=0; i<TEMPLATES; i++)
629 {
630 if(!pfread(trashbuf,sizeof(mapscr),f))
631 {
632 goto error;
633 }
634 }
635 if (num_maps>1) //dungeon templates
636 {
637 for (int32_t i=0; i<TEMPLATES; i++)
638 {
639 if(!pfread(trashbuf,sizeof(mapscr),f))
640 {
641 goto error;
642 }
643 }
644 }
645
646 //yay! it worked! close the file and say everything was ok.
647 pack_fclose(f);
648 return true;
649
650 error:
651 pack_fclose(f);
652 return false;*/
653 }
654
655 bool valid_zqt(const char *filename)
656 {
657 PACKFILE *f=NULL;
658 bool isvalid;
659 int32_t error;
660 f=open_quest_file(&error, filename, false);
661
662 if(!f)
663 {
664 // setPackfilePassword(NULL);
665 return false;
666 }
667
668 isvalid=valid_zqt(f);
669
670 clear_quest_tmpfile();
671 pack_fclose(f);
672
673 // setPackfilePassword(NULL);
674 return isvalid;
675 }
676
677 /*
678 .qst file history
679
680 .qst files have always been compressed using allegro's packfiles.
681
682 At some point, an encoding layer was added. The two layers look like this:
683
684 1) The top layer is from us. See decode_file_007.
685 [0-24] Preamble "Zelda Classic Quest File"
686 [25-28] Initial decoding seed value.
687 [29-X] Allegro-compressed payload (AKA "packed" file), but XOR'd based on seed value
688 [last 4] Checksum
689
690 2) The bottom layer is a "compressed packed file" from Allegro 4. The entire payload
691 is XOR'd with a password (datapwd). Once that is undone, the first four bytes are "slh!",
692 followed by a lzss compressed representation of the payload (from allergo' packfile compression).
693 The oldest quests skip the password part.
694
695 Simply, the job of this function is to peel away the top layer.
696
697 With this second layer of encryption, the data isn't any more secure, and adds a significant delay
698 in opening and saving files. There is no version field, so they decryption key is
699 found via trial-by-error (very slow!)
700
701 There are other file types of interest:
702 - .zqt: quest template files, skips top-layer encryption pass
703 - .qsu: "unencoded" (and uncompressed) files; skips encryption and compression (also makes the longtan password moot)
704 - .qu?: same as above. automated backup files
705 - .qb?: same as above. automated backup files
706 - .qt?: compressed and encrypted (or not encrypted, as of May 2023)
707
708 May 2023: .qst files are now saved without the top layer encoding, and no allegro packfile password. The first bytes of these
709 files are now "slh!.AG ZC Enhanced Quest File".
710 The following command will take an existing qst file and upgrade it: `./zquest -unencrypt-qst <input> <output>`
711 */
712 798 PACKFILE *open_quest_file(int32_t *open_error, const char *filename, bool show_progress)
713 {
714
1/2
✓ Branch 0 taken 798 times.
✗ Branch 1 not taken.
798 if (show_progress)
715 {
716 box_start(1, "Loading Quest", get_zc_font(font_lfont), font, true);
717 }
718
719 798 auto unencrypted_result = try_open_maybe_legacy_encoded_file(filename, ENC_STR, nullptr, QH_NEWIDSTR, QH_IDSTR);
720
2/2
✓ Branch 0 taken 313 times.
✓ Branch 1 taken 485 times.
798 if (unencrypted_result.decoded_pf)
721 313 return unencrypted_result.decoded_pf;
722
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 485 times.
485 if (unencrypted_result.not_found)
723 {
724 *open_error = qe_notfound;
725 return nullptr;
726 }
727
728 // Everything below here is legacy code - recently saved quest files will have
729 // returned by now.
730 // The only replay qst file that is still using this legacy encoding is `link_to_the_zelda.qst`.
731
732 // Note: although this is primarily for loading .qst files, it can also handle all of the
733 // file types mentioned in the comment above. No need to be told if the file being loaded
734 // is encrypted or compressed, we can do some simple and fast checks to determine how to load it.
735 485 bool top_layer_compressed = unencrypted_result.top_layer_compressed;
736 485 bool compressed = unencrypted_result.compressed;
737 485 bool encrypted = unencrypted_result.encrypted;
738
739 char tmpfilename[L_tmpnam];
740 485 temp_name(tmpfilename);
741 char percent_done[30];
742 485 int32_t current_method=0;
743
744 PACKFILE *f;
745 485 const char *passwd= encrypted ? datapwd : "";
746
747 // oldquest flag is set when an unencrypted qst file is suspected.
748 485 bool oldquest = false;
749 int32_t ret;
750
751
1/2
✓ Branch 0 taken 485 times.
✗ Branch 1 not taken.
485 if(strcmp(filename, "default.qst")!=0)
752 {
753 485 box_out(filename);
754 485 }
755 else
756 {
757 box_out("new quest"); // Or whatever
758 }
759 485 box_out("...");
760 485 box_eol();
761 485 box_eol();
762
763
1/2
✓ Branch 0 taken 485 times.
✗ Branch 1 not taken.
485 if(encrypted)
764 {
765 485 box_out("Decrypting...");
766 485 box_save_x();
767 485 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_MAX-1, top_layer_compressed, passwd);
768
769
2/2
✓ Branch 0 taken 422 times.
✓ Branch 1 taken 63 times.
485 if(ret)
770 {
771
1/3
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
63 switch(ret)
772 {
773 case 1:
774 box_out("error.");
775 box_eol();
776 box_end(true);
777 *open_error=qe_notfound;
778 return NULL;
779
780 case 2:
781 box_out("error.");
782 box_eol();
783 box_end(true);
784 *open_error=qe_internal;
785 return NULL;
786 // be sure not to delete tmpfilename now...
787 }
788
789
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(ret==5) //old encryption?
790 {
791 63 current_method++;
792 63 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
793 63 box_out(percent_done);
794 63 box_load_x();
795 63 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_211B9, strstr(filename, ".dat#")!=NULL, passwd);
796 63 }
797
798
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(ret==5) //old encryption?
799 {
800 63 current_method++;
801 63 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
802 63 box_out(percent_done);
803 63 box_load_x();
804 63 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B185, strstr(filename, ".dat#")!=NULL, passwd);
805 63 }
806
807
2/2
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 18 times.
63 if(ret==5) //old encryption?
808 {
809 18 current_method++;
810 18 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
811 18 box_out(percent_done);
812 18 box_load_x();
813 18 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B105, strstr(filename, ".dat#")!=NULL, passwd);
814 18 }
815
816
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 12 times.
63 if(ret==5) //old encryption?
817 {
818 12 current_method++;
819 12 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
820 12 box_out(percent_done);
821 12 box_load_x();
822 12 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B104, strstr(filename, ".dat#")!=NULL, passwd);
823 12 }
824
825
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(ret)
826 {
827 oldquest = true;
828 passwd="";
829 }
830 63 }
831
832 485 box_out("okay.");
833 485 box_eol();
834 485 }
835 else
836 {
837 oldquest = true;
838 }
839
840 485 box_out("Opening...");
841
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 485 times.
485 f = pack_fopen_password(oldquest ? filename : tmpfilename, compressed ? F_READ_PACKED : F_READ, passwd);
842
1/2
✓ Branch 0 taken 485 times.
✗ Branch 1 not taken.
485 if(!f)
843 {
844 if((compressed==1)&&(errno==EDOM))
845 {
846 f = pack_fopen_password(oldquest ? filename : tmpfilename, F_READ, passwd);
847 }
848
849 if(!f)
850 {
851 if(!oldquest)
852 {
853 delete_file(tmpfilename);
854 }
855 box_out("error.");
856 box_eol();
857 box_end(true);
858 *open_error=qe_invalid;
859 return NULL;
860 }
861 }
862
863
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 485 times.
485 if(!oldquest)
864 {
865 485 delete_file(tmpfilename);
866 485 }
867
868 485 box_out("okay.");
869 485 box_eol();
870
871 485 return f;
872 798 }
873
874 PACKFILE *open_quest_template(zquestheader *Header, const char *filename, bool validate)
875 {
876 PACKFILE *f=NULL;
877 int32_t open_error=0;
878
879 if (Header->templatepath[0] != 0)
880 {
881 // TODO: should be safe to remove this, no one seems to use custom quest templates.
882 filename=Header->templatepath;
883 }
884
885 f=open_quest_file(&open_error, filename, false);
886
887 if(!f)
888 {
889 return NULL;
890 }
891
892 if(validate)
893 {
894 if(!valid_zqt(f))
895 {
896 jwin_alert("Error","Invalid Quest Template",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
897 pack_fclose(f);
898 clear_quest_tmpfile();
899 return NULL;
900 }
901 }
902
903 return f;
904 }
905
906 static bool init_section(zquestheader *Header, int32_t section_id, miscQdata *Misc, zctune *tunes, bool validate, const char* filename)
907 {
908 // The only time the player uses this is to init tiles for some quests 1.90 or older. See readtiles.
909 if (get_app_id() == App::zelda)
910 assert(section_id == ID_TILES);
911
912 combosread=false;
913 mapsread=false;
914 fixffcs=false;
915
916 switch(section_id)
917 {
918 case ID_RULES:
919 case ID_STRINGS:
920 case ID_MISC:
921 case ID_TILES:
922 case ID_COMBOS:
923 case ID_CSETS:
924 case ID_MAPS:
925 case ID_DMAPS:
926 case ID_DOORS:
927 case ID_ITEMS:
928 case ID_WEAPONS:
929 case ID_COLORS:
930 case ID_ICONS:
931 case ID_INITDATA:
932 case ID_GUYS:
933 case ID_MIDIS:
934 case ID_CHEATS:
935 case ID_ITEMDROPSETS:
936 case ID_FAVORITES:
937 break;
938
939 default:
940 return false;
941 break;
942 }
943
944 int32_t ret;
945 word version, build;
946 PACKFILE *f=NULL;
947
948 //why is this here?
949 /*
950 if(colordata==NULL)
951 return false;
952 */
953
954 //setPackfilePassword(datapwd);
955 f=open_quest_template(Header, filename, validate);
956
957 if(!f) //no file, nothing to delete
958 {
959 // setPackfilePassword(NULL);
960 return false;
961 }
962
963 ret=get_version_and_build(f, &version, &build);
964
965 if(ret||(version==0))
966 {
967 pack_fclose(f);
968 clear_quest_tmpfile();
969
970 // setPackfilePassword(NULL);
971 return false;
972 }
973
974 if(!find_section(f, section_id))
975 {
976 al_trace("Can't find section!\n");
977 pack_fclose(f);
978 clear_quest_tmpfile();
979
980 //setPackfilePassword(NULL);
981 return false;
982 }
983
984 switch(section_id)
985 {
986 case ID_RULES:
987 //rules
988 ret=readrules(f, Header);
989 break;
990
991 case ID_STRINGS:
992 //strings
993 ret=readstrings(f, Header);
994 break;
995
996 case ID_MISC:
997 //misc data
998 ret=readmisc(f, Header, Misc);
999 break;
1000
1001 case ID_TILES:
1002 //tiles
1003 ret=readtiles(f, newtilebuf, Header, version, build, 0, NEWMAXTILES, true);
1004 break;
1005
1006 case ID_COMBOS:
1007 //combos
1008 clear_combos();
1009 ret=readcombos(f, Header, version, build, 0, MAXCOMBOS);
1010 combosread=true;
1011 break;
1012
1013 case ID_COMBOALIASES:
1014 //combos
1015 ret=readcomboaliases(f, Header, version, build);
1016 break;
1017
1018 case ID_CSETS:
1019 //color data
1020 ret=readcolordata(f, Misc, version, build, 0, newerpdTOTAL);
1021 break;
1022
1023 case ID_MAPS:
1024 //maps
1025 ret=readmaps(f, Header);
1026 mapsread=true;
1027 break;
1028
1029 case ID_DMAPS:
1030 //dmaps
1031 ret=readdmaps(f, Header, version, build, 0, MAXDMAPS);
1032 break;
1033
1034 case ID_DOORS:
1035 //door combo sets
1036 ret=readdoorcombosets(f, Header);
1037 break;
1038
1039 case ID_ITEMS:
1040 //items
1041 ret=readitems(f, version, build);
1042 break;
1043
1044 case ID_WEAPONS:
1045 //weapons
1046 ret=readweapons(f, Header);
1047 break;
1048
1049 case ID_COLORS:
1050 //misc. colors
1051 ret=readmisccolors(f, Header, Misc);
1052 break;
1053
1054 case ID_ICONS:
1055 //game icons
1056 ret=readgameicons(f, Header, Misc);
1057 break;
1058
1059 case ID_INITDATA:
1060 //initialization data
1061 ret=readinitdata(f, Header);
1062 break;
1063
1064 case ID_GUYS:
1065 //guys
1066 ret=readguys(f, Header);
1067 break;
1068
1069 case ID_MIDIS:
1070 //midis
1071 ret=readtunes(f, Header, tunes);
1072 break;
1073
1074 case ID_CHEATS:
1075 //cheat codes
1076 ret=readcheatcodes(f, Header);
1077 break;
1078
1079 case ID_ITEMDROPSETS:
1080 //item drop sets
1081 // Why is this one commented out?
1082 //ret=readitemdropsets(f, (int32_t)version, (word)build);
1083 break;
1084
1085 case ID_FAVORITES:
1086 // favorite combos and aliases
1087 ret=readfavorites(f, version);
1088 break;
1089
1090 default:
1091 ret=-1;
1092 break;
1093 }
1094
1095 pack_fclose(f);
1096 clear_quest_tmpfile();
1097
1098 //setPackfilePassword(NULL);
1099 if(!ret)
1100 {
1101 return true;
1102 }
1103
1104 return false;
1105 }
1106
1107 bool init_tiles_for_190(bool validate, zquestheader *Header)
1108 {
1109 return init_section(Header, ID_TILES, NULL, NULL, validate, "assets/190_tiles.qst");
1110 }
1111
1112 bool init_tiles(bool validate, zquestheader *Header)
1113 {
1114 return init_section(Header, ID_TILES, NULL, NULL, validate, "modules/classic/default.qst");
1115 }
1116
1117 bool init_combos(bool validate, zquestheader *Header)
1118 {
1119 return init_section(Header, ID_COMBOS, NULL, NULL, validate, "modules/classic/default.qst");
1120 }
1121
1122 bool init_colordata(bool validate, zquestheader *Header, miscQdata *Misc)
1123 {
1124 return init_section(Header, ID_CSETS, Misc, NULL, validate, "modules/classic/default.qst");
1125 }
1126
1127 798 void init_spritelists()
1128 {
1129
2/2
✓ Branch 0 taken 608 times.
✓ Branch 1 taken 190 times.
798 if(FFCore.quest_format[vZelda] < 0x255)
1130 {
1131 608 guys.setMax(255);
1132 608 items.setMax(255);
1133 608 Ewpns.setMax(255);
1134 608 Lwpns.setMax(255);
1135 608 chainlinks.setMax(255);
1136 608 decorations.setMax(255);
1137 608 particles.setMax(255);
1138 608 }
1139 else
1140 {
1141 190 guys.setMax(255);
1142 190 items.setMax(255);
1143 190 Ewpns.setMax(255);
1144 190 Lwpns.setMax(255);
1145 190 chainlinks.setMax(255);
1146 190 decorations.setMax(255);
1147 190 particles.setMax(255*((255*4)+1)); //255 per sprite that can use particles; guys, items, ewpns, lwpns, +HERO
1148 }
1149 798 }
1150
1151 312 bool reset_items(bool validate, zquestheader *Header)
1152 {
1153 312 bool ret = true;
1154
1/2
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
312 if (get_app_id() == App::zquest)
1155 ret = init_section(Header, ID_ITEMS, NULL, NULL, validate, "modules/classic/default.qst");
1156
1157
2/2
✓ Branch 0 taken 312 times.
✓ Branch 1 taken 79872 times.
80184 for(int32_t i=0; i<MAXITEMS; i++) reset_itemname(i);
1158
1159 312 return ret;
1160 }
1161
1162 bool reset_guys()
1163 {
1164 // The .dat file's guys definitions are always synchronised with defdata.cpp's - even the tile settings.
1165 init_guys(V_GUYS);
1166 return true;
1167 }
1168
1169 bool reset_wpns(bool validate, zquestheader *Header)
1170 {
1171 bool ret = true;
1172 if (get_app_id() == App::zquest)
1173 ret = init_section(Header, ID_WEAPONS, NULL, NULL, validate, "modules/classic/default.qst");
1174
1175 for(int32_t i=0; i<MAXWPNS; i++)
1176 reset_weaponname(i);
1177
1178 return ret;
1179 }
1180
1181 bool reset_mapstyles(bool validate, miscQdata *Misc)
1182 {
1183 Misc->colors.blueframe_tile = 20044;
1184 Misc->colors.blueframe_cset = 0;
1185 Misc->colors.triforce_tile = 23461;
1186 Misc->colors.triforce_cset = 1;
1187 Misc->colors.triframe_tile = 18752;
1188 Misc->colors.triframe_cset = 1;
1189 Misc->colors.overworld_map_tile = 16990;
1190 Misc->colors.overworld_map_cset = 2;
1191 Misc->colors.HCpieces_tile = 21160;
1192 Misc->colors.HCpieces_cset = 8;
1193 Misc->colors.dungeon_map_tile = 19651;
1194 Misc->colors.dungeon_map_cset = 8;
1195 return true;
1196 }
1197
1198 370 int32_t get_qst_buffers()
1199 {
1200 370 TheMaps.resize(MAPSCRS);
1201 370 old_combo_pages.resize(MAPSCRS);
1202 370 map_autolayers.resize(6);
1203
1204 370 Z_message("OK\n");
1205
1206 // The vast majority of finished quests (and I presume this will be consistent for all time) use < 1000 strings in total.
1207 // (Shoelace's "Hero of Dreams" uses 1415.)
1208 // So let's be a bit generous and allow 4096 initially.
1209 // In the rare event that a quest overshoots this mark, we'll reallocate to the full 65535 later.
1210 // I tested it and it worked without flaw on 6/6/11. - L.
1211 // 2022: bumped from 4096 to 8192 to avoid a bug where the Strings menu shows (None) strings when the list passes
1212 // this threshold. Possibly some bug related to `msglistcache` to being reset?
1213 // See https://discord.com/channels/876899628556091432/992984989073416242
1214 370 msg_strings_size = 8192;
1215
1216
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 370 times.
370 MsgStrings = new MsgStr[msg_strings_size];
1217
1218 //memset(MsgStrings, 0, sizeof(MsgStr)*msg_strings_size);
1219
2/2
✓ Branch 0 taken 3031040 times.
✓ Branch 1 taken 370 times.
3031410 for(auto q = 0; q < msg_strings_size; ++q)
1220 {
1221 3031040 MsgStrings[q].clear();
1222 3031040 }
1223
1224
1/2
✓ Branch 0 taken 370 times.
✗ Branch 1 not taken.
370 if((DMaps=new dmap[MAXDMAPS])==NULL)
1225 return 0;
1226
1227
1228
1229 370 combobuf.clear();
1230 370 combobuf.resize(MAXCOMBOS);
1231
1232
1233
1/2
✓ Branch 0 taken 370 times.
✗ Branch 1 not taken.
370 if((colordata=(byte*)malloc(psTOTAL255))==NULL)
1234 return 0;
1235
1236 370 free_newtilebuf();
1237
1/2
✓ Branch 0 taken 370 times.
✗ Branch 1 not taken.
370 if((newtilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
1238 return 0;
1239
1240 370 memset(newtilebuf, 0, NEWMAXTILES*sizeof(tiledata));
1241 //Z_message("Performed memset on tiles\n");
1242 370 clear_tiles(newtilebuf);
1243 //Z_message("Performed clear_tiles()\n");
1244
1245
2/2
✓ Branch 0 taken 357 times.
✓ Branch 1 taken 13 times.
370 if (get_app_id() == App::zquest)
1246 {
1247
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if((grabtilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
1248 return 0;
1249
1250 13 memset(grabtilebuf, 0, NEWMAXTILES*sizeof(tiledata));
1251 13 clear_tiles(grabtilebuf);
1252 13 }
1253
1254
1/2
✓ Branch 0 taken 370 times.
✗ Branch 1 not taken.
370 if((trashbuf=(byte*)malloc(100000))==NULL)
1255 return 0;
1256
1257 // Big, ugly band-aid here. Perhaps the most common cause of random crashes
1258 // has been inadvertently accessing itemsbuf[-1]. All such crashes should be
1259 // fixed by ensuring there's actually itemdata there.
1260 // If you change this, be sure to update del_qst_buffers, too.
1261
1262
1/2
✓ Branch 0 taken 370 times.
✗ Branch 1 not taken.
370 if((itemsbuf=(itemdata*)malloc(sizeof(itemdata)*(MAXITEMS+1)))==NULL)
1263 return 0;
1264
1265 370 memset(itemsbuf,0,sizeof(itemdata)*(MAXITEMS+1));
1266 370 itemsbuf++;
1267
1268
1/2
✓ Branch 0 taken 370 times.
✗ Branch 1 not taken.
370 if((wpnsbuf=(wpndata*)malloc(sizeof(wpndata)*MAXWPNS))==NULL)
1269 return 0;
1270
1271 370 memset(wpnsbuf,0,sizeof(wpndata)*MAXWPNS);
1272
1273
1/2
✓ Branch 0 taken 370 times.
✗ Branch 1 not taken.
370 if((guysbuf=(guydata*)malloc(sizeof(guydata)*MAXGUYS))==NULL)
1274 return 0;
1275
1276 370 memset(guysbuf,0,sizeof(guydata)*MAXGUYS);
1277
1278
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 370 times.
370 if((combo_class_buf=(comboclass*)malloc(sizeof(comboclass)*cMAX))==NULL)
1279 return 0;
1280
1281 370 return 1;
1282 370 }
1283
1284
1285 693 void free_newtilebuf()
1286 {
1287
2/2
✓ Branch 0 taken 324 times.
✓ Branch 1 taken 369 times.
693 if(newtilebuf)
1288 {
1289
2/2
✓ Branch 0 taken 69498000 times.
✓ Branch 1 taken 324 times.
69498324 for(int32_t i=0; i<NEWMAXTILES; i++)
1290
2/2
✓ Branch 0 taken 214500 times.
✓ Branch 1 taken 69283500 times.
138781500 if(newtilebuf[i].data)
1291 69283500 free(newtilebuf[i].data);
1292
1293 324 free(newtilebuf);
1294 324 newtilebuf = 0;
1295 324 }
1296 693 }
1297
1298 323 void free_grabtilebuf()
1299 {
1300
2/2
✓ Branch 0 taken 312 times.
✓ Branch 1 taken 11 times.
323 if (get_app_id() == App::zquest)
1301 {
1302
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(grabtilebuf)
1303 {
1304
2/2
✓ Branch 0 taken 2359500 times.
✓ Branch 1 taken 11 times.
2359511 for(int32_t i=0; i<NEWMAXTILES; i++)
1305
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2359500 times.
2359500 if(grabtilebuf[i].data) free(grabtilebuf[i].data);
1306
1307 11 free(grabtilebuf);
1308 11 grabtilebuf = 0;
1309 11 }
1310 11 }
1311 323 }
1312
1313 323 void del_qst_buffers()
1314 {
1315
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 323 times.
✓ Branch 2 taken 323 times.
✗ Branch 3 not taken.
323 if(MsgStrings) delete[] MsgStrings;
1316
1317
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 323 times.
✓ Branch 2 taken 323 times.
✗ Branch 3 not taken.
323 if (DMaps) delete[] DMaps;
1318
1319 323 combobuf.clear();
1320
1321
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 323 times.
323 if(colordata) free(colordata);
1322
1323 323 free_newtilebuf();
1324 323 free_grabtilebuf();
1325
1326
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 323 times.
323 if(trashbuf) free(trashbuf);
1327
1328 // See get_qst_buffers
1329
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 323 times.
323 if(itemsbuf)
1330 {
1331 323 itemsbuf--;
1332 323 free(itemsbuf);
1333 323 }
1334
1335
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 323 times.
323 if(wpnsbuf) free(wpnsbuf);
1336
1337
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 323 times.
323 if(guysbuf) free(guysbuf);
1338
1339
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 323 times.
323 if(combo_class_buf) free(combo_class_buf);
1340 323 }
1341
1342 18 bool init_palnames()
1343 {
1344 // if(palnames==NULL)
1345 // return false;
1346
1347
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 18 times.
9234 for(int32_t x=0; x<MAXLEVELS; x++)
1348 {
1349
4/4
✓ Branch 0 taken 9162 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 18 times.
9216 switch(x)
1350 {
1351 case 0:
1352 18 sprintf(palnames[x],"Overworld");
1353 18 break;
1354
1355 case 10:
1356 18 sprintf(palnames[x],"Caves");
1357 18 break;
1358
1359 case 11:
1360 18 sprintf(palnames[x],"Passageways");
1361 18 break;
1362
1363 default:
1364 9162 sprintf(palnames[x],"%c",0);
1365 9162 break;
1366 }
1367 9216 }
1368
1369 18 return true;
1370 }
1371
1372 100188 static void *read_block(PACKFILE *f, int32_t size, int32_t alloc_size)
1373 {
1374 void *p;
1375
1376
1/2
✓ Branch 0 taken 100188 times.
✗ Branch 1 not taken.
100188 p = _AL_MALLOC(MAX(size, alloc_size));
1377
1378
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100188 times.
100188 if(!p)
1379 {
1380 return NULL;
1381 }
1382
1383
1/2
✓ Branch 0 taken 100188 times.
✗ Branch 1 not taken.
100188 if(!pfread(p,size,f))
1384 {
1385 _AL_FREE(p);
1386 return NULL;
1387 }
1388
1389
1/2
✓ Branch 0 taken 100188 times.
✗ Branch 1 not taken.
100188 if(pack_ferror(f))
1390 {
1391 _AL_FREE(p);
1392 return NULL;
1393 }
1394
1395 100188 return p;
1396 100188 }
1397
1398 // Only use for reading parts of older quests (Header->zelda_version <= 0x192)
1399 static const byte* legacy_skip_flags;
1400
1401 /* read_midi:
1402 * Reads MIDI data from a datafile (this is not the same thing as the
1403 * standard midi file format).
1404 */
1405
1406 10260 static MIDI *read_midi(PACKFILE *f)
1407 {
1408 MIDI *m;
1409 int32_t c;
1410 10260 int16_t divisions=0;
1411 10260 int32_t len=0;
1412
1413 10260 m = (MIDI*)_AL_MALLOC(sizeof(MIDI));
1414
1415
1/2
✓ Branch 0 taken 10260 times.
✗ Branch 1 not taken.
10260 if(!m)
1416 {
1417 return NULL;
1418 }
1419
1420
2/2
✓ Branch 0 taken 328320 times.
✓ Branch 1 taken 10260 times.
338580 for(c=0; c<MIDI_TRACKS; c++)
1421 {
1422 328320 m->track[c].len = 0;
1423 328320 m->track[c].data = NULL;
1424 328320 }
1425
1426 10260 p_mgetw(&divisions,f);
1427 10260 m->divisions=divisions;
1428
1429
2/2
✓ Branch 0 taken 328320 times.
✓ Branch 1 taken 10260 times.
338580 for(c=0; c<MIDI_TRACKS; c++)
1430 {
1431 328320 p_mgetl(&len,f);
1432 328320 m->track[c].len=len;
1433
1434
2/2
✓ Branch 0 taken 228132 times.
✓ Branch 1 taken 100188 times.
328320 if(m->track[c].len > 0)
1435 {
1436 100188 m->track[c].data = (byte*)read_block(f, m->track[c].len, 0);
1437
1438
1/2
✓ Branch 0 taken 100188 times.
✗ Branch 1 not taken.
100188 if(!m->track[c].data)
1439 {
1440 destroy_midi(m);
1441 return NULL;
1442 }
1443 100188 }
1444 328320 }
1445
1446 LOCK_DATA(m, sizeof(MIDI));
1447
1448
2/2
✓ Branch 0 taken 328320 times.
✓ Branch 1 taken 10260 times.
338580 for(c=0; c<MIDI_TRACKS; c++)
1449 {
1450
2/2
✓ Branch 0 taken 100188 times.
✓ Branch 1 taken 228132 times.
328320 if(m->track[c].data)
1451 {
1452 LOCK_DATA(m->track[c].data, m->track[c].len);
1453 100188 }
1454 328320 }
1455
1456 10260 return m;
1457 10260 }
1458
1459 void clear_combo(int32_t i)
1460 {
1461 combobuf[i].clear();
1462 }
1463
1464 void clear_combos()
1465 {
1466 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
1467 clear_combo(tmpcounter);
1468 }
1469
1470 void pack_combos()
1471 {
1472 int32_t di = 0;
1473
1474 for(int32_t si=0; si<1024; si+=2)
1475 combobuf[di++] = combobuf[si];
1476
1477 for(; di<1024; di++)
1478 clear_combo(di);
1479 }
1480
1481 477 void reset_tunes(zctune *tune)
1482 {
1483
2/2
✓ Branch 0 taken 120204 times.
✓ Branch 1 taken 477 times.
120681 for(int32_t i=0; i<MAXCUSTOMTUNES; i++)
1484 {
1485 120204 tune[i].reset();
1486 120204 }
1487 477 }
1488
1489 int32_t doortranslations_u[9][4]=
1490 {
1491 {37,38,53,54},
1492 {37,38,39,40},
1493 {37,38,55,56},
1494 {37,38,39,40},
1495 {37,38,53,54},
1496 {37,38,53,54},
1497 {37,38,53,54},
1498 {7,8,23,24},
1499 {7,8,41,42}
1500 };
1501
1502 int32_t doortranslations_d[9][4]=
1503 {
1504 {117,118,133,134},
1505 {135,136,133,134},
1506 {119,120,133,134},
1507 {135,136,133,134},
1508 {117,118,133,134},
1509 {117,118,133,134},
1510 {117,118,133,134},
1511 {151,152,167,168},
1512 {137,138,167,168},
1513 };
1514
1515 //enum {dt_pass=0, dt_lock, dt_shut, dt_boss, dt_olck, dt_osht, dt_obos, dt_wall, dt_bomb, dt_walk, dt_max};
1516 int32_t doortranslations_l[9][6]=
1517 {
1518 {66,67,82,83,98,99},
1519 {66,68,82,84,98,100},
1520 {66,69,82,85,98,101},
1521 {66,68,82,84,98,100},
1522 {66,67,82,83,98,99},
1523 {66,67,82,83,98,99},
1524 {66,67,82,83,98,99},
1525 {64,65,80,81,96,97},
1526 {64,65,80,114,96,97},
1527 };
1528
1529 int32_t doortranslations_r[9][6]=
1530 {
1531
1532 {76,77,92,93,108,109},
1533 {75,77,91,93,107,109},
1534 {74,77,90,93,106,109},
1535 {75,77,91,93,107,109},
1536 {76,77,92,93,108,109},
1537 {76,77,92,93,108,109},
1538 {76,77,92,93,108,109},
1539 {78,79,94,95,110,111},
1540 {78,79,125,95,110,111},
1541 };
1542
1543 858450 int32_t tdcmbdat(int32_t map, int32_t scr, int32_t pos)
1544 {
1545 858450 byte old_cpage = old_combo_pages[map*MAPSCRS+scr];
1546 858450 return (TheMaps[map*MAPSCRS+TEMPLATE].data[pos]&0xFF) + (old_cpage<<8);
1547 }
1548
1549 840750 int32_t tdcmbcset(int32_t map, int32_t scr, int32_t pos)
1550 {
1551 //these are here to bypass compiler warnings about unused arguments
1552 840750 map=map;
1553 840750 scr=scr;
1554 840750 pos=pos;
1555
1556 //what does this function do?
1557 // return TheMaps[map*MAPSCRS+TEMPLATE].cset[pos];
1558 840750 return 2;
1559 }
1560
1561 22848 int32_t MakeDoors(int32_t map, int32_t scr)
1562 {
1563
2/2
✓ Branch 0 taken 18423 times.
✓ Branch 1 taken 4425 times.
22848 if(!(TheMaps[map*MAPSCRS+scr].valid&mVALID))
1564 {
1565 18423 return 0;
1566 }
1567
1568 4425 DoorComboSet tempdcs{};
1569
1570 //up
1571
2/2
✓ Branch 0 taken 39825 times.
✓ Branch 1 taken 4425 times.
44250 for(int32_t i=0; i<9; i++)
1572 {
1573
2/2
✓ Branch 0 taken 159300 times.
✓ Branch 1 taken 39825 times.
199125 for(int32_t j=0; j<4; j++)
1574 {
1575 159300 tempdcs.doorcombo_u[i][j]=tdcmbdat(map,scr,doortranslations_u[i][j]);
1576 159300 tempdcs.doorcset_u[i][j]=tdcmbcset(map,scr,doortranslations_u[i][j]);
1577 159300 }
1578 39825 }
1579
1580 4425 tempdcs.bombdoorcombo_u[0]=tdcmbdat(map,scr,57);
1581 4425 tempdcs.bombdoorcset_u[0]=tdcmbcset(map,scr,57);
1582 4425 tempdcs.bombdoorcombo_u[1]=tdcmbdat(map,scr,58);
1583 4425 tempdcs.bombdoorcset_u[1]=tdcmbcset(map,scr,58);
1584 4425 tempdcs.walkthroughcombo[0]=tdcmbdat(map,scr,34);
1585 4425 tempdcs.walkthroughcset[0]=tdcmbdat(map,scr,34);
1586
1587 //down
1588
2/2
✓ Branch 0 taken 39825 times.
✓ Branch 1 taken 4425 times.
44250 for(int32_t i=0; i<9; i++)
1589 {
1590
2/2
✓ Branch 0 taken 159300 times.
✓ Branch 1 taken 39825 times.
199125 for(int32_t j=0; j<4; j++)
1591 {
1592 159300 tempdcs.doorcombo_d[i][j]=tdcmbdat(map,scr,doortranslations_d[i][j]);
1593 159300 tempdcs.doorcset_d[i][j]=tdcmbcset(map,scr,doortranslations_d[i][j]);
1594 159300 }
1595 39825 }
1596
1597 4425 tempdcs.bombdoorcombo_d[0]=tdcmbdat(map,scr,121);
1598
1599 4425 tempdcs.bombdoorcset_d[0]=tdcmbcset(map,scr,121);
1600 4425 tempdcs.bombdoorcombo_d[1]=tdcmbdat(map,scr,122);
1601 4425 tempdcs.bombdoorcset_d[1]=tdcmbcset(map,scr,122);
1602 4425 tempdcs.walkthroughcombo[1]=tdcmbdat(map,scr,34);
1603 4425 tempdcs.walkthroughcset[1]=tdcmbdat(map,scr,34);
1604
1605 //left
1606 // TheMaps[i*MAPSCRS+j].warpdmap=TheOldMap.warpdmap;
1607
2/2
✓ Branch 0 taken 39825 times.
✓ Branch 1 taken 4425 times.
44250 for(int32_t i=0; i<9; i++)
1608 {
1609
2/2
✓ Branch 0 taken 238950 times.
✓ Branch 1 taken 39825 times.
278775 for(int32_t j=0; j<6; j++)
1610 {
1611 238950 tempdcs.doorcombo_l[i][j]=tdcmbdat(map,scr,doortranslations_l[i][j]);
1612 238950 tempdcs.doorcset_l[i][j]=tdcmbcset(map,scr,doortranslations_l[i][j]);
1613 238950 }
1614 39825 }
1615
1616
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4425 times.
4425 for(int32_t j=0; j>6; j++)
1617 {
1618 if((j!=2)&&(j!=3))
1619 {
1620 tempdcs.doorcombo_l[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].data[doortranslations_l[dt_bomb][j]];
1621 tempdcs.doorcset_l[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].cset[doortranslations_l[dt_bomb][j]];
1622 }
1623 }
1624
1625 4425 tempdcs.bombdoorcombo_l[0]=0;
1626 4425 tempdcs.bombdoorcset_l[0]=tdcmbcset(map,scr,115);
1627 4425 tempdcs.bombdoorcombo_l[1]=tdcmbdat(map,scr,115);
1628 4425 tempdcs.bombdoorcset_l[1]=tdcmbcset(map,scr,115);
1629 4425 tempdcs.bombdoorcombo_l[2]=0;
1630 4425 tempdcs.bombdoorcset_l[2]=tdcmbcset(map,scr,115);
1631 4425 tempdcs.walkthroughcombo[2]=tdcmbdat(map,scr,34);
1632 4425 tempdcs.walkthroughcset[2]=tdcmbdat(map,scr,34);
1633
1634 //right
1635
2/2
✓ Branch 0 taken 39825 times.
✓ Branch 1 taken 4425 times.
44250 for(int32_t i=0; i<9; i++)
1636 {
1637
2/2
✓ Branch 0 taken 238950 times.
✓ Branch 1 taken 39825 times.
278775 for(int32_t j=0; j<6; j++)
1638 {
1639 238950 tempdcs.doorcombo_r[i][j]=tdcmbdat(map,scr,doortranslations_r[i][j]);
1640 238950 tempdcs.doorcset_r[i][j]=tdcmbcset(map,scr,doortranslations_r[i][j]);
1641 238950 }
1642 39825 }
1643
1644
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4425 times.
4425 for(int32_t j=0; j>6; j++)
1645 {
1646 if((j!=2)&&(j!=3))
1647 {
1648 tempdcs.doorcombo_r[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].data[doortranslations_r[dt_bomb][j]];
1649 tempdcs.doorcset_r[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].cset[doortranslations_r[dt_bomb][j]];
1650 }
1651 }
1652
1653 4425 tempdcs.bombdoorcombo_r[0]=0;
1654 4425 tempdcs.bombdoorcset_r[0]=tdcmbcset(map,scr,124);
1655 4425 tempdcs.bombdoorcombo_r[1]=tdcmbdat(map,scr,124);
1656 4425 tempdcs.bombdoorcset_r[1]=tdcmbcset(map,scr,124);
1657 4425 tempdcs.bombdoorcombo_r[2]=0;
1658 4425 tempdcs.bombdoorcset_r[2]=tdcmbcset(map,scr,124);
1659 4425 tempdcs.walkthroughcombo[3]=tdcmbdat(map,scr,34);
1660 4425 tempdcs.walkthroughcset[3]=tdcmbdat(map,scr,34);
1661
1662 int32_t k;
1663
1664
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 10306 times.
10366 for(k=0; k<door_combo_set_count; k++)
1665 {
1666
2/2
✓ Branch 0 taken 5941 times.
✓ Branch 1 taken 4365 times.
10306 if(DoorComboSets[k]==tempdcs)
1667 {
1668 4365 break;
1669 }
1670 5941 }
1671
1672
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4425 times.
4425 if (k >= DoorComboSets.size())
1673 {
1674 return 0;
1675 }
1676
1677
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 4365 times.
4425 if(k==door_combo_set_count)
1678 {
1679 60 DoorComboSets[k]=tempdcs;
1680 60 DoorComboSetNames[k] = fmt::format("Door Combo Set {}", k);
1681 60 ++door_combo_set_count;
1682 60 }
1683
1684 4425 return k;
1685 /*
1686 doorcombo_u[9][4];
1687 doorcset_u[9][4];
1688 doorcombo_d[9][4];
1689 doorcset_d[9][4];
1690 doorcombo_l[9][6];
1691 doorcset_l[9][6];
1692 doorcombo_r[9][6];
1693 doorcset_r[9][6];
1694 bombdoorcombo_u[2];
1695 bombdoorcset_u[2];
1696 bombdoorcombo_d[2];
1697 bombdoorcset_d[2];
1698 bombdoorcombo_l[3];
1699 bombdoorcset_l[3];
1700 bombdoorcombo_r[3];
1701 bombdoorcset_r[3];
1702 walkthroughcombo[4];
1703 walkthroughcset[4];
1704 */
1705 22848 }
1706
1707 2924544 INLINE int32_t tcmbdat2(int32_t map, int32_t scr, int32_t pos)
1708 {
1709 2924544 byte old_cpage = old_combo_pages[map*MAPSCRS+scr];
1710 2924544 return (TheMaps[map*MAPSCRS+TEMPLATE2].data[pos]&0xFF) + (old_cpage<<8);
1711 }
1712
1713 2924544 INLINE int32_t tcmbcset2(int32_t map, int32_t pos)
1714 {
1715
1716 2924544 return TheMaps[map*MAPSCRS+TEMPLATE2].cset[pos];
1717 }
1718
1719 2924544 INLINE int32_t tcmbflag2(int32_t map, int32_t pos)
1720 {
1721 2924544 return TheMaps[map*MAPSCRS+TEMPLATE2].sflag[pos];
1722 }
1723
1724
1725 83 void get_questpwd(char *encrypted_pwd, int16_t pwdkey, char *pwd)
1726 {
1727 char temp_pwd[30];
1728 83 memset(temp_pwd,0,30);
1729
1730
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 8 times.
83 if(pwdkey!=0)
1731 {
1732 75 memcpy(temp_pwd,encrypted_pwd,30);
1733 75 temp_pwd[29]=0;
1734
1735
2/2
✓ Branch 0 taken 2250 times.
✓ Branch 1 taken 75 times.
2325 for(int32_t i=0; i<30; i++)
1736 {
1737 2250 temp_pwd[i] -= pwdkey;
1738 2250 int32_t t=pwdkey>>15;
1739 2250 pwdkey = (pwdkey<<1)+t;
1740 2250 }
1741 75 }
1742
1743 83 memcpy(pwd,temp_pwd,30);
1744 83 }
1745
1746
1747 257 bool devpwd()
1748 {
1749 #ifdef _DEBUG
1750 return true;
1751 #endif
1752 #if DEVLEVEL > 3
1753 return true;
1754 #endif
1755
1/2
✓ Branch 0 taken 257 times.
✗ Branch 1 not taken.
257 return !strcmp(zc_get_config("dev","pwd","",App::zquest), (char*)clavio) || is_ci();
1756 }
1757 bool check_questpwd(zquestheader *Header, char *pwd)
1758 {
1759 if(devpwd())
1760 return true;
1761 if((!strcmp(pwd, (char*)clavio)))
1762 return true;
1763 cvs_MD5Context ctx;
1764 uint8_t md5sum[16];
1765
1766 cvs_MD5Init(&ctx);
1767 cvs_MD5Update(&ctx, (const uint8_t*)pwd, (unsigned)strlen(pwd));
1768 cvs_MD5Final(md5sum, &ctx);
1769
1770 return (memcmp(Header->pwd_hash,md5sum,16)==0);
1771 }
1772
1773 static char const* key_exts[KEYFILE_NUMTY] = {"key", "zcheat", "zpwd"};
1774 static bool key_hashed[KEYFILE_NUMTY] = {false, true, false};
1775 static char const* key_namestr[KEYFILE_NUMTY] = {"Master","Cheat","ZPwd"};
1776
1777 static bool check_keyfile(char const* path, char const* ext, bool hashed, char const* typestr, zquestheader* Header)
1778 {
1779 char keyfilename[2048];
1780 replace_extension(keyfilename, path, ext, 2047);
1781 if(!exists(keyfilename))
1782 return false;
1783 bool ret = false;
1784
1785 char password[QSTPWD_LEN] = {0}, pwd[32] = {0};
1786 PACKFILE *fp = pack_fopen_password(keyfilename, F_READ,"");
1787 char msg[80] = {0};
1788 pfread(msg, 80, fp);
1789 if(strcmp(msg,"ZQuest Auto-Generated Quest Password Key File. DO NOT EDIT!"))
1790 {
1791 zprint2("Found %s Key File '%s' (invalid header)\n", typestr, keyfilename);
1792 pack_fclose(fp);
1793 return false;
1794 }
1795 int16_t ver;
1796 byte bld;
1797 p_igetw(&ver, fp);
1798 p_getc(&bld, fp);
1799 pfread(password, QSTPWD_LEN, fp, true);
1800 if(hashed)
1801 {
1802 char unhashed_pw[QSTPWD_LEN] = {0};
1803
1804 char hashmap = 'Z';
1805 hashmap += 'Q';
1806 hashmap += 'U';
1807 hashmap += 'E';
1808 hashmap += 'S';
1809 hashmap += 'T';
1810
1811 for ( int32_t q = 0; q < QSTPWD_LEN; ++q )
1812 unhashed_pw[q] = password[q] - hashmap;
1813
1814 ret = check_questpwd(Header, unhashed_pw);
1815 }
1816 else ret = check_questpwd(Header, password);
1817 pack_fclose(fp);
1818 zprint2("Found %s Key File '%s' (%s access)\n",
1819 typestr, keyfilename, ret ? "valid" : "invalid");
1820 return ret;
1821 }
1822
1823 bool check_keyfiles(char const* path, vector<uint> types, zquestheader* Header)
1824 {
1825 char exedir[PATH_MAX] = {0};
1826 extract_name(path, exedir, FILENAMEALL);
1827 char const* paths[] = {path, exedir};
1828 for(uint keyty : types)
1829 {
1830 if(keyty >= KEYFILE_NUMTY)
1831 continue;
1832 for(char const* p : paths)
1833 {
1834 if(check_keyfile(p, key_exts[keyty], key_hashed[keyty], key_namestr[keyty], Header))
1835 return true;
1836 }
1837 }
1838 return false;
1839 }
1840
1841 433 void print_quest_metadata(zquestheader const& tempheader, char const* path, byte qst_num)
1842 {
1843 433 zprint2("\n");
1844 433 zprint2("[QUEST METADATA]\n");
1845
1/2
✓ Branch 0 taken 433 times.
✗ Branch 1 not taken.
433 if(path)
1846 433 zprint2("Path: %s\n", path);
1847
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 106 times.
433 if(tempheader.title[0])
1848 327 zprint2("Title: %s\n", tempheader.title);
1849 433 zprint2("ZC Version: %s\n", tempheader.getVerStr());
1850
2/2
✓ Branch 0 taken 175 times.
✓ Branch 1 taken 258 times.
433 if(tempheader.new_version_id_date_day)
1851 175 zprint2("ZC Build Date: %d-%d-%d %s %s\n", tempheader.new_version_id_date_year, tempheader.new_version_id_date_month, tempheader.new_version_id_date_day, tempheader.build_timestamp, tempheader.build_timezone);
1852
2/2
✓ Branch 0 taken 246 times.
✓ Branch 1 taken 187 times.
433 if(tempheader.version[0])
1853 246 zprint2("Qst Version: %s\n", tempheader.version);
1854
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 106 times.
433 if(tempheader.author[0])
1855 327 zprint2("Author: %s\n", tempheader.author);
1856 433 zprint2("\n");
1857 433 }
1858
1859 810 int32_t readheader(PACKFILE *f, zquestheader *Header, byte printmetadata)
1860 {
1861 int32_t dummy;
1862 810 zquestheader tempheader{};
1863
2/2
✓ Branch 0 taken 798 times.
✓ Branch 1 taken 12 times.
810 tempheader.filename = Header->filename;
1864 char dummybuf[80];
1865 byte temp_map_count;
1866 byte temp_midi_flags[MIDIFLAGS_SIZE];
1867 word version;
1868 char temp_pwd[30], temp_pwd2[30];
1869 int16_t temp_pwdkey;
1870 cvs_MD5Context ctx;
1871 798 memset(temp_midi_flags, 0, MIDIFLAGS_SIZE);
1872 798 memset(FFCore.quest_format, 0, sizeof(FFCore.quest_format));
1873
1874
1875
1876
2/4
✓ Branch 0 taken 798 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 798 times.
798 if(!pfread(tempheader.id_str,sizeof(tempheader.id_str),f)) // first read old header
1877 {
1878 Z_message("Unable to read header string\n");
1879 return qe_invalid;
1880 }
1881
1882 // check header
1883
2/2
✓ Branch 0 taken 774 times.
✓ Branch 1 taken 24 times.
798 if(strcmp(tempheader.id_str,QH_NEWIDSTR))
1884 {
1885
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(strcmp(tempheader.id_str,QH_IDSTR))
1886 {
1887 Z_message("Invalid header string: '%s' (was expecting '%s' or '%s')\n", tempheader.id_str, QH_IDSTR, QH_NEWIDSTR);
1888 return qe_invalid;
1889 }
1890 24 }
1891
1892 798 int32_t templatepath_len=0;
1893
1894 798 tempheader.external_zinfo = false;
1895 798 read_zinfo = false;
1896
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 774 times.
798 if(!strcmp(tempheader.id_str,QH_IDSTR)) //pre-1.93 version
1897 {
1898 byte padding;
1899
1900
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&padding,f))
1901 {
1902 return qe_invalid;
1903 }
1904
1905
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_igetw(&tempheader.zelda_version,f))
1906 {
1907 return qe_invalid;
1908 }
1909
1910 24 FFCore.quest_format[vZelda] = tempheader.zelda_version;
1911
1912
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(tempheader.zelda_version > ZELDA_VERSION)
1913 {
1914 return qe_version;
1915 }
1916
1917 24 FFCore.quest_format[vZelda] = tempheader.zelda_version;
1918
1919
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(strcmp(tempheader.id_str,QH_IDSTR))
1920 {
1921 return qe_invalid;
1922 }
1923
1924
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(bad_version(tempheader.zelda_version))
1925 {
1926 return qe_obsolete;
1927 }
1928
1929
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
24 if(!p_igetw(&tempheader.internal,f))
1930 {
1931 return qe_invalid;
1932 }
1933
1934
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
24 if(!p_getc(&tempheader.quest_number,f))
1935 {
1936 return qe_invalid;
1937 }
1938
1939 24 FFCore.quest_format[qQuestNumber] = tempheader.quest_number;
1940
1941
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(&quest_rules[0],2,f))
1942 {
1943 return qe_invalid;
1944 }
1945
1946
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&temp_map_count,f))
1947 {
1948 return qe_invalid;
1949 }
1950
1951 24 FFCore.quest_format[qMapCount] = temp_map_count;
1952
1953
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&tempheader.old_str_count,f))
1954 {
1955 return qe_invalid;
1956 }
1957
1958
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
24 if(!p_getc(&tempheader.data_flags[ZQ_TILES],f))
1959 {
1960 return qe_invalid;
1961 }
1962
1963
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
24 if(!pfread(temp_midi_flags,4,f))
1964 {
1965 return qe_invalid;
1966 }
1967
1968
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&tempheader.data_flags[ZQ_CHEATS2],f))
1969 {
1970 return qe_invalid;
1971 }
1972
1973
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(dummybuf,14,f))
1974 {
1975 return qe_invalid;
1976 }
1977
1978
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(&quest_rules[2],2,f))
1979 {
1980 return qe_invalid;
1981 }
1982
1983
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&dummybuf,f))
1984 {
1985 return qe_invalid;
1986 }
1987
1988
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(tempheader.version,9,f))
1989 {
1990 return qe_invalid;
1991 }
1992
1993
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(tempheader.title,sizeof(tempheader.title),f))
1994 {
1995 return qe_invalid;
1996 }
1997 // These fields are expected to end in null bytes!
1998 24 tempheader.title[sizeof(tempheader.title)-1] = 0;
1999
2000
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(tempheader.author,sizeof(tempheader.author),f))
2001 {
2002 return qe_invalid;
2003 }
2004 24 tempheader.author[sizeof(tempheader.author)-1] = 0;
2005
2006
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&padding,f))
2007 {
2008 return qe_invalid;
2009 }
2010
2011
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_igetw(&temp_pwdkey,f))
2012 {
2013 return qe_invalid;
2014 }
2015
2016
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(temp_pwd,30,f))
2017 {
2018 return qe_invalid;
2019 }
2020
2021 24 get_questpwd(temp_pwd, temp_pwdkey, temp_pwd2);
2022
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 cvs_MD5Init(&ctx);
2023
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 cvs_MD5Update(&ctx, (const uint8_t*)temp_pwd2, (unsigned)strnlen(temp_pwd2, 30));
2024
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 cvs_MD5Final(tempheader.pwd_hash, &ctx);
2025
2026
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(tempheader.zelda_version < 0x177) // lacks new header stuff...
2027 {
2028 //memset(tempheader.minver,0,20); // char minver[9], byte build, byte foo[10]
2029 // Not anymore...
2030 memset(tempheader.minver,0,17);
2031 tempheader.build=0;
2032 tempheader.use_keyfile=0;
2033 memset(tempheader.old_foo, 0, 9);
2034 }
2035 else
2036 {
2037
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(tempheader.minver,9,f))
2038 {
2039 return qe_invalid;
2040 }
2041
2042
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&tempheader.build,f))
2043 {
2044 return qe_invalid;
2045 }
2046
2047 24 FFCore.quest_format[vBuild] = tempheader.build;
2048
2049
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&tempheader.use_keyfile,f))
2050 {
2051 return qe_invalid;
2052 }
2053
2054
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(dummybuf,9,f))
2055 {
2056 return qe_invalid;
2057 }
2058 } // starting at minver
2059
2060
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 6 times.
24 if(tempheader.zelda_version < 0x187) // lacks newer header stuff...
2061 {
2062 6 memset(&quest_rules[4],0,16); // word rules3..rules10
2063 6 }
2064 else
2065 {
2066
2/4
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
18 if(!pfread(&quest_rules[4],16,f)) // read new header additions
2067 {
2068 return qe_invalid; // starting at rules3
2069 }
2070
2071
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 6 times.
18 if(tempheader.zelda_version <= 0x190)
2072 {
2073
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 set_qr(qr_MEANPLACEDTRAPS,0);
2074 12 }
2075 }
2076
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 unpack_qrs();
2077
2078
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
30 if((tempheader.zelda_version < 0x192)||
2079
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((tempheader.zelda_version == 0x192)&&(tempheader.build<149)))
2080 {
2081
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 6 times.
24 set_qr(qr_BRKNSHLDTILES,(get_qr(qr_BRKBLSHLDS_DEP)));
2082
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 set_bit(deprecated_rules,qr_BRKBLSHLDS_DEP,(get_qr(qr_BRKBLSHLDS_DEP)));
2083
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 set_qr(qr_BRKBLSHLDS_DEP,0);
2084 18 }
2085
2086
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
18 if(tempheader.zelda_version >= 0x192) // lacks newer header stuff...
2087 {
2088 6 byte *mf=temp_midi_flags;
2089
2090
3/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 4 times.
6 if((tempheader.zelda_version == 0x192)&&(tempheader.build<178))
2091 {
2092 4 mf=(byte*)dummybuf;
2093 4 }
2094
2095
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!pfread(mf,32,f)) // read new header additions
2096 {
2097 return qe_invalid; // starting at foo2
2098 }
2099
2100
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!pfread(dummybuf,18,f)) // read new header additions
2101 {
2102 return qe_invalid; // starting at foo2
2103 }
2104 6 }
2105
2106
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
24 if((tempheader.zelda_version < 0x192)||
2107
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((tempheader.zelda_version == 0x192)&&(tempheader.build<145)))
2108 {
2109 18 memset(tempheader.templatepath,0,2048);
2110 18 }
2111 else
2112 {
2113 if(!pfread(tempheader.templatepath,280,f)) // read templatepath
2114 {
2115 return qe_invalid;
2116 }
2117 }
2118
2119
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
30 if((tempheader.zelda_version < 0x192)||
2120
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((tempheader.zelda_version == 0x192)&&(tempheader.build<186)))
2121 {
2122 24 tempheader.use_keyfile=0;
2123 24 }
2124 24 }
2125 else
2126 {
2127 //section id
2128
2/4
✓ Branch 0 taken 774 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 774 times.
✗ Branch 3 not taken.
774 if(!p_mgetl(&dummy,f))
2129 {
2130 return qe_invalid;
2131 }
2132
2133 //section version info
2134
2/4
✓ Branch 0 taken 774 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 774 times.
✗ Branch 3 not taken.
774 if(!p_igetw(&version,f))
2135 {
2136 return qe_invalid;
2137 }
2138
2139 774 FFCore.quest_format[vHeader] = version;
2140
2141
2/4
✓ Branch 0 taken 774 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 774 times.
✗ Branch 3 not taken.
774 if(!p_igetw(&dummy,f))
2142 {
2143 return qe_invalid;
2144 }
2145
2146 //section size
2147
2/4
✓ Branch 0 taken 774 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 774 times.
✗ Branch 3 not taken.
774 if(!p_igetl(&dummy,f))
2148 {
2149 return qe_invalid;
2150 }
2151
2152 //finally... section data
2153
2/4
✓ Branch 0 taken 774 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 774 times.
✗ Branch 3 not taken.
774 if(!p_igetw(&tempheader.zelda_version,f))
2154 {
2155 return qe_invalid;
2156 }
2157
2158 774 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2159
2160 //do some quick checking...
2161
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 774 times.
774 if(tempheader.zelda_version > ZELDA_VERSION)
2162 {
2163 return qe_version;
2164 }
2165
2166
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 774 times.
774 if(strcmp(tempheader.id_str,QH_NEWIDSTR))
2167 {
2168 return qe_invalid;
2169 }
2170
2171
2/4
✓ Branch 0 taken 774 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 774 times.
774 if(bad_version(tempheader.zelda_version))
2172 {
2173 return qe_obsolete;
2174 }
2175
2176
2/4
✓ Branch 0 taken 774 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 774 times.
✗ Branch 3 not taken.
774 if(!p_getc(&tempheader.build,f))
2177 {
2178 return qe_invalid;
2179 }
2180
2181 774 FFCore.quest_format[vBuild] = tempheader.build;
2182
2183
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 715 times.
774 if(version<3)
2184 {
2185
2/4
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 59 times.
✗ Branch 3 not taken.
59 if(!pfread(temp_pwd,30,f))
2186 {
2187 return qe_invalid;
2188 }
2189
2190
2/4
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 59 times.
✗ Branch 3 not taken.
59 if(!p_igetw(&temp_pwdkey,f))
2191 {
2192 return qe_invalid;
2193 }
2194
2195 59 get_questpwd(temp_pwd, temp_pwdkey, temp_pwd2);
2196
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 cvs_MD5Init(&ctx);
2197
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 cvs_MD5Update(&ctx, (const uint8_t*)temp_pwd2, (unsigned)strnlen(temp_pwd2, 30));
2198
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 cvs_MD5Final(tempheader.pwd_hash, &ctx);
2199 59 }
2200 else
2201 {
2202
2/4
✓ Branch 0 taken 715 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 715 times.
715 if(!pfread(tempheader.pwd_hash,sizeof(tempheader.pwd_hash),f))
2203 {
2204 return qe_invalid;
2205 }
2206 }
2207
2208
2/4
✓ Branch 0 taken 774 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 774 times.
✗ Branch 3 not taken.
774 if(!p_igetw(&tempheader.internal,f))
2209 {
2210 return qe_invalid;
2211 }
2212
2213
2/4
✓ Branch 0 taken 774 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 774 times.
✗ Branch 3 not taken.
774 if(!p_getc(&tempheader.quest_number,f))
2214 {
2215 return qe_invalid;
2216 }
2217
2218 774 FFCore.quest_format[qQuestNumber] = tempheader.quest_number;
2219
2220 774 size_t versz = version < 8 ? 9 : 16;
2221
2/4
✓ Branch 0 taken 774 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 774 times.
✗ Branch 3 not taken.
774 if(!pfread(tempheader.version,versz,f))
2222 {
2223 return qe_invalid;
2224 }
2225
2226 //FFCore.quest_format[qQuestVersion] = tempheader.version;
2227 //needs to be copied as char[9] or stored as a s.str
2228
2/4
✓ Branch 0 taken 774 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 774 times.
✗ Branch 3 not taken.
774 if(!pfread(tempheader.minver,versz,f))
2229 {
2230 return qe_invalid;
2231 }
2232
2233 //FFCore.quest_format[qMinQuestVersion] = tempheader.minver;
2234
2/4
✓ Branch 0 taken 774 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 774 times.
✗ Branch 3 not taken.
774 if(!pfread(tempheader.title,sizeof(tempheader.title),f))
2235 {
2236 return qe_invalid;
2237 }
2238 774 tempheader.title[sizeof(tempheader.title)-1] = 0;
2239
2240
2/4
✓ Branch 0 taken 774 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 774 times.
✗ Branch 3 not taken.
774 if(!pfread(tempheader.author,sizeof(tempheader.author),f))
2241 {
2242 return qe_invalid;
2243 }
2244 774 tempheader.author[sizeof(tempheader.author)-1] = 0;
2245
2246
2/4
✓ Branch 0 taken 774 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 774 times.
✗ Branch 3 not taken.
774 if(!p_getc(&tempheader.use_keyfile,f))
2247 {
2248 return qe_invalid;
2249 }
2250
2251 /*
2252 if(!pfread(tempheader.data_flags,sizeof(tempheader.data_flags),f))
2253 {
2254 return qe_invalid;
2255 }
2256 */
2257
2/4
✓ Branch 0 taken 774 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 774 times.
✗ Branch 3 not taken.
774 if(!p_getc(&tempheader.data_flags[ZQ_TILES],f))
2258 {
2259 return qe_invalid;
2260 }
2261
2262
2/4
✓ Branch 0 taken 774 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 774 times.
✗ Branch 3 not taken.
774 if(!pfread(&dummybuf,4,f))
2263 {
2264 return qe_invalid;
2265 }
2266
2267
2/4
✓ Branch 0 taken 774 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 774 times.
✗ Branch 3 not taken.
774 if(!p_getc(&tempheader.data_flags[ZQ_CHEATS2],f))
2268 {
2269 return qe_invalid;
2270 }
2271
2272
2/4
✓ Branch 0 taken 774 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 774 times.
✗ Branch 3 not taken.
774 if(!pfread(dummybuf,14,f))
2273 {
2274 return qe_invalid;
2275 }
2276
2277 774 templatepath_len=sizeof(tempheader.templatepath);
2278
2279
2/2
✓ Branch 0 taken 715 times.
✓ Branch 1 taken 59 times.
774 if(version==1)
2280 {
2281 59 templatepath_len=280;
2282 59 }
2283
2284
2/4
✓ Branch 0 taken 774 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 774 times.
✗ Branch 3 not taken.
774 if(!pfread(tempheader.templatepath,templatepath_len,f))
2285 {
2286 return qe_invalid;
2287 }
2288
2289
2/4
✓ Branch 0 taken 774 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 774 times.
✗ Branch 3 not taken.
774 if(!p_getc(&temp_map_count,f))
2290 {
2291 return qe_invalid;
2292 }
2293
2294
2/2
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 584 times.
774 if(version>=4)
2295 {
2296
2/4
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 190 times.
✗ Branch 3 not taken.
190 if(!p_igetl(&tempheader.version_major,f))
2297 {
2298 return qe_invalid;
2299 }
2300
2/4
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 190 times.
✗ Branch 3 not taken.
190 if(!p_igetl(&tempheader.version_minor,f))
2301 {
2302 return qe_invalid;
2303 }
2304
2/4
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 190 times.
✗ Branch 3 not taken.
190 if(!p_igetl(&tempheader.version_patch,f))
2305 {
2306 return qe_invalid;
2307 }
2308
2/4
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 190 times.
✗ Branch 3 not taken.
190 if(!p_igetl(&tempheader.new_version_id_fourth,f))
2309 {
2310 return qe_invalid;
2311 }
2312
2/4
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 190 times.
✗ Branch 3 not taken.
190 if(!p_igetl(&tempheader.new_version_id_alpha,f))
2313 {
2314 return qe_invalid;
2315 }
2316
2/4
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 190 times.
✗ Branch 3 not taken.
190 if(!p_igetl(&tempheader.new_version_id_beta,f))
2317 {
2318 return qe_invalid;
2319 }
2320
2/4
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 190 times.
✗ Branch 3 not taken.
190 if(!p_igetl(&tempheader.new_version_id_gamma,f))
2321 {
2322 return qe_invalid;
2323 }
2324
2/4
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 190 times.
✗ Branch 3 not taken.
190 if(!p_igetl(&tempheader.new_version_id_release,f))
2325 {
2326 return qe_invalid;
2327 }
2328
2329 // 2.55 alpha 86 incorrectly used 56 as the second version component. Fix that here.
2330
3/6
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 146 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 44 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
190 if (tempheader.version_major == 2 && tempheader.version_minor == 56 && tempheader.new_version_id_alpha == 86)
2331 tempheader.version_minor = 55;
2332
2333
2/4
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 190 times.
✗ Branch 3 not taken.
190 if(!p_igetw(&tempheader.new_version_id_date_year,f))
2334 {
2335 return qe_invalid;
2336 }
2337
2/4
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 190 times.
✗ Branch 3 not taken.
190 if(!p_getc(&tempheader.new_version_id_date_month,f))
2338 {
2339 return qe_invalid;
2340 }
2341
2/4
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 190 times.
✗ Branch 3 not taken.
190 if(!p_getc(&tempheader.new_version_id_date_day,f))
2342 {
2343 return qe_invalid;
2344 }
2345
2/4
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 190 times.
✗ Branch 3 not taken.
190 if(!p_getc(&tempheader.new_version_id_date_hour,f))
2346 {
2347 return qe_invalid;
2348 }
2349
2/4
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 190 times.
✗ Branch 3 not taken.
190 if(!p_getc(&tempheader.new_version_id_date_minute,f))
2350 {
2351 return qe_invalid;
2352 }
2353
2354
2/4
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 190 times.
✗ Branch 3 not taken.
190 if(!pfread(tempheader.new_version_devsig,256,f))
2355 {
2356 return qe_invalid;
2357 }
2358
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if(!strcmp(tempheader.new_version_devsig, "Venrob"))
2359 strcpy(tempheader.new_version_devsig, "EmilyV99");
2360
2/4
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 190 times.
✗ Branch 3 not taken.
190 if(!pfread(tempheader.new_version_compilername,256,f))
2361 {
2362 return qe_invalid;
2363 }
2364
2/4
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 190 times.
✗ Branch 3 not taken.
190 if(!pfread(tempheader.new_version_compilerversion,256,f))
2365 {
2366 return qe_invalid;
2367 }
2368
2/4
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 190 times.
✗ Branch 3 not taken.
190 if(!pfread(tempheader.product_name,1024,f))
2369 {
2370 return qe_invalid;
2371 }
2372
2373
2/4
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 190 times.
✗ Branch 3 not taken.
190 if(!p_getc(&tempheader.compilerid,f))
2374 {
2375 return qe_invalid;
2376 }
2377
2/4
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 190 times.
✗ Branch 3 not taken.
190 if(!p_igetl(&tempheader.compilerversionnumber_first,f))
2378 {
2379 return qe_invalid;
2380 }
2381
2/4
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 190 times.
✗ Branch 3 not taken.
190 if(!p_igetl(&tempheader.compilerversionnumber_second,f))
2382 {
2383 return qe_invalid;
2384 }
2385
2/4
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 190 times.
✗ Branch 3 not taken.
190 if(!p_igetl(&tempheader.compilerversionnumber_third,f))
2386 {
2387 return qe_invalid;
2388 }
2389
2/4
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 190 times.
✗ Branch 3 not taken.
190 if(!p_igetl(&tempheader.compilerversionnumber_fourth,f))
2390 {
2391 return qe_invalid;
2392 }
2393
2/4
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 190 times.
✗ Branch 3 not taken.
190 if(!p_igetw(&tempheader.developerid,f))
2394 {
2395 return qe_invalid;
2396 }
2397
2/4
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 190 times.
190 if(!pfread(tempheader.made_in_module_name,1024,f))
2398 {
2399 return qe_invalid;
2400 }
2401
2/4
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 190 times.
190 if(!pfread(tempheader.build_datestamp,256,f))
2402 {
2403 return qe_invalid;
2404 }
2405
2/4
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 190 times.
190 if(!pfread(tempheader.build_timestamp,256,f))
2406 {
2407 return qe_invalid;
2408 }
2409 190 }
2410 else // <4
2411 {
2412 584 tempheader.version_major = 0;
2413 584 tempheader.version_minor = 0;
2414 584 tempheader.version_patch = 0;
2415 584 tempheader.new_version_id_fourth = 0;
2416 584 tempheader.new_version_id_alpha = 0;
2417 584 tempheader.new_version_id_beta = 0;
2418 584 tempheader.new_version_id_gamma = 0;
2419 584 tempheader.new_version_id_release = 0;
2420 584 tempheader.new_version_id_date_year = 0;
2421 584 tempheader.new_version_id_date_month = 0;
2422 584 tempheader.new_version_id_date_day = 0;
2423 584 tempheader.new_version_id_date_hour = 0;
2424 584 tempheader.new_version_id_date_minute = 0;
2425
2426 584 memset(tempheader.new_version_devsig, 0, 256);
2427 584 memset(tempheader.new_version_compilername, 0, 256);
2428 584 memset(tempheader.new_version_compilerversion, 0, 256);
2429 584 memset(tempheader.product_name, 0, 1024);
2430 584 strcpy(tempheader.product_name, "ZQuest Classic");
2431
2432 584 tempheader.compilerid = 0;
2433 584 tempheader.compilerversionnumber_first = 0;
2434 584 tempheader.compilerversionnumber_second = 0;
2435 584 tempheader.compilerversionnumber_third = 0;
2436 584 tempheader.compilerversionnumber_fourth = 0;
2437 584 tempheader.developerid = 0;
2438
2439 584 memset(tempheader.made_in_module_name, 0, 1024);
2440 584 memset(tempheader.build_datestamp, 0, 256);
2441 584 memset(tempheader.build_timestamp, 0, 256);
2442 }
2443
2444
2/2
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 584 times.
774 if ( version >= 5 )
2445 {
2446
2/4
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 190 times.
✗ Branch 3 not taken.
190 if(!pfread(tempheader.build_timezone,6,f))
2447 {
2448 return qe_invalid;
2449 }
2450 190 }
2451 else // < 5
2452 {
2453 584 memset(tempheader.build_timezone, 0, 6);
2454 }
2455
2/2
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 584 times.
774 if ( version >= 6 )
2456 {
2457 byte b;
2458
2/4
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 190 times.
✗ Branch 3 not taken.
190 if(!p_getc(&b,f))
2459 {
2460 return qe_invalid;
2461 }
2462 190 tempheader.external_zinfo = b?true:false;
2463 190 read_zinfo = true;
2464 190 }
2465
2466
2/2
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 584 times.
774 if(version >= 7)
2467 {
2468
2/4
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 190 times.
✗ Branch 3 not taken.
190 if(!p_getc(&(tempheader.new_version_is_nightly),f))
2469 {
2470 return qe_invalid;
2471 }
2472 190 }
2473 else
2474 {
2475 584 tempheader.new_version_is_nightly = false;
2476
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 584 times.
584 if(tempheader.zelda_version < 0x255)
2477 {
2478
2/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 525 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 59 times.
584 switch(tempheader.zelda_version)
2479 {
2480 case 0x254:
2481 tempheader.version_major = 2;
2482 tempheader.version_minor = 54;
2483 break;
2484 case 0x250:
2485
7/16
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 33 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 24 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 6 times.
✓ Branch 11 taken 402 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 16 times.
✓ Branch 14 taken 28 times.
✓ Branch 15 taken 16 times.
525 switch(tempheader.build)
2486 {
2487 case 19:
2488 tempheader.version_major = 2;
2489 tempheader.version_minor = 50;
2490 tempheader.new_version_id_gamma = 1;
2491 break;
2492 case 20:
2493 tempheader.version_major = 2;
2494 tempheader.version_minor = 50;
2495 tempheader.new_version_id_gamma = 2;
2496 break;
2497 case 21:
2498 tempheader.version_major = 2;
2499 tempheader.version_minor = 50;
2500 tempheader.new_version_id_gamma = 3;
2501 break;
2502 case 22:
2503 tempheader.version_major = 2;
2504 tempheader.version_minor = 50;
2505 tempheader.new_version_id_gamma = 4;
2506 break;
2507 case 23:
2508 tempheader.version_major = 2;
2509 tempheader.version_minor = 50;
2510 tempheader.new_version_id_gamma = 5;
2511 break;
2512 case 24:
2513 33 tempheader.version_major = 2;
2514 33 tempheader.version_minor = 50;
2515 33 tempheader.new_version_id_release = -1;
2516 33 break;
2517 case 25:
2518 tempheader.version_major = 2;
2519 tempheader.version_minor = 50;
2520 tempheader.version_patch = 1;
2521 tempheader.new_version_id_gamma = 1;
2522 break;
2523 case 26:
2524 24 tempheader.version_major = 2;
2525 24 tempheader.version_minor = 50;
2526 24 tempheader.version_patch = 1;
2527 24 tempheader.new_version_id_gamma = 2;
2528 24 break;
2529 case 27:
2530 tempheader.version_major = 2;
2531 tempheader.version_minor = 50;
2532 tempheader.version_patch = 1;
2533 tempheader.new_version_id_gamma = 3;
2534 break;
2535 case 28:
2536 6 tempheader.version_major = 2;
2537 6 tempheader.version_minor = 50;
2538 6 tempheader.version_patch = 1;
2539 6 tempheader.new_version_id_release = -1;
2540 6 break;
2541 case 29:
2542 402 tempheader.version_major = 2;
2543 402 tempheader.version_minor = 50;
2544 402 tempheader.version_patch = 2;
2545 402 tempheader.new_version_id_release = -1;
2546 402 break;
2547 case 30:
2548 tempheader.version_major = 2;
2549 tempheader.version_minor = 50;
2550 tempheader.version_patch = 3;
2551 tempheader.new_version_id_gamma = 1;
2552 break;
2553 case 31:
2554 16 tempheader.version_major = 2;
2555 16 tempheader.version_minor = 53;
2556 16 tempheader.new_version_id_gamma = -1;
2557 16 break;
2558 case 32:
2559 28 tempheader.version_major = 2;
2560 28 tempheader.version_minor = 53;
2561 28 tempheader.new_version_id_release = -1;
2562 28 break;
2563 case 33:
2564 16 tempheader.version_major = 2;
2565 16 tempheader.version_minor = 53;
2566 16 tempheader.version_patch = 1;
2567 16 break;
2568 }
2569 525 break;
2570
2571 case 0x211:
2572 tempheader.version_major = 2;
2573 tempheader.version_minor = 11;
2574 tempheader.new_version_id_beta = tempheader.build;
2575 break;
2576 case 0x210:
2577 59 tempheader.version_major = 2;
2578 59 tempheader.version_minor = 10;
2579 59 tempheader.new_version_id_beta = tempheader.build;
2580 59 break;
2581 }
2582 584 }
2583 }
2584
2585
2/2
✓ Branch 0 taken 146 times.
✓ Branch 1 taken 628 times.
774 if (version>=9)
2586 {
2587 146 std::string version_string;
2588
2/4
✓ Branch 0 taken 146 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 146 times.
✗ Branch 3 not taken.
146 if(!p_getcstr(&version_string, f))
2589 {
2590 return qe_invalid;
2591 }
2592
2593 146 strncpy(tempheader.zelda_version_string, version_string.c_str(), sizeof(tempheader.zelda_version_string));
2594 146 snprintf(tempheader.zelda_version_string, sizeof(tempheader.zelda_version_string), "%s", version_string.c_str());
2595
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 146 times.
146 }
2596 else
2597 {
2598 628 snprintf(tempheader.zelda_version_string, sizeof(tempheader.zelda_version_string), "%d.%d.%d", tempheader.version_major, tempheader.version_minor, tempheader.version_patch);
2599 }
2600 }
2601
2602
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 786 times.
798 if(printmetadata)
2603 {
2604
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 print_quest_metadata(tempheader, loading_qst_name, loading_qst_num);
2605 12 }
2606
2607 //{ Version Warning
2608
1/2
✓ Branch 0 taken 798 times.
✗ Branch 1 not taken.
798 int32_t vercmp = tempheader.compareVer();
2609
3/6
✓ Branch 0 taken 798 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 798 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 798 times.
✗ Branch 5 not taken.
798 int32_t astatecmp = compare(int32_t(tempheader.getAlphaState()), getAlphaState());
2610
2/4
✓ Branch 0 taken 798 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 798 times.
✗ Branch 3 not taken.
798 int32_t avercmp = compare(tempheader.getAlphaVer(), 0);
2611
4/6
✓ Branch 0 taken 798 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 146 times.
✓ Branch 3 taken 652 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 146 times.
944 if(vercmp > 0 || (!vercmp &&
2612
2/4
✓ Branch 0 taken 146 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 146 times.
✗ Branch 3 not taken.
146 (astatecmp > 0 || (!astatecmp &&
2613 146 avercmp > 0))))
2614 {
2615 bool r = true;
2616 if(loadquest_report)
2617 {
2618 enter_sys_pal();
2619 AlertDialog("Quest saved in newer version",
2620 "This quest was last saved in a newer version of ZQuest."
2621 " Attempting to load this quest may not work correctly; to"
2622 " avoid issues, try loading this quest in at least '" + std::string(tempheader.getVerStr()) + "'"
2623 "\n\nWould you like to continue loading anyway? (Not recommended)",
2624 [&](bool ret,bool)
2625 {
2626 r = ret;
2627 }).show();
2628 exit_sys_pal();
2629 }
2630 if(!r)
2631 return qe_silenterr;
2632 }
2633
2/4
✓ Branch 0 taken 798 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 798 times.
✗ Branch 3 not taken.
798 else if(tempheader.compareDate() > 0)
2634 {
2635 bool r = true;
2636 if(loadquest_report)
2637 {
2638 enter_sys_pal();
2639 AlertDialog("Quest saved in newer build",
2640 fmt::format("This quest was last saved in a newer build of ZQuest, and may have"
2641 " issues loading in this build."
2642 "\n{}"
2643 "\n\nWould you like to continue loading anyway?",
2644 tempheader.getVerCmpStr()),
2645 [&](bool ret,bool)
2646 {
2647 r = ret;
2648 }).show();
2649 exit_sys_pal();
2650 }
2651 if(!r)
2652 return qe_silenterr;
2653 }
2654 //}
2655
2656 798 read_ext_zinfo = tempheader.external_zinfo;
2657
2658
1/2
✓ Branch 0 taken 798 times.
✗ Branch 1 not taken.
798 *Header = tempheader;
2659 798 map_count=temp_map_count;
2660 798 memcpy(midi_flags, temp_midi_flags, MIDIFLAGS_SIZE);
2661
2662
1/2
✓ Branch 0 taken 798 times.
✗ Branch 1 not taken.
798 unpack_qrs();
2663
2664 798 return 0;
2665 822 }
2666
2667 7895 int32_t readrules(PACKFILE *f, zquestheader *Header)
2668 {
2669
2/2
✓ Branch 0 taken 7872 times.
✓ Branch 1 taken 23 times.
7895 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_rules);
2670
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7895 times.
7895 if (should_skip)
2671 return 0;
2672
2673 int32_t dummy;
2674 7895 zquestheader tempheader = *Header;
2675 7895 word s_version=0;
2676 7895 dword compatrule_version=0;
2677
2678
2/2
✓ Branch 0 taken 454 times.
✓ Branch 1 taken 7441 times.
7895 if(tempheader.zelda_version >= 0x193)
2679 {
2680 //section version info
2681
2/4
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 454 times.
✗ Branch 3 not taken.
454 if(!p_igetw(&s_version,f))
2682 {
2683 return qe_invalid;
2684 }
2685
2686 454 FFCore.quest_format[vRules] = s_version;
2687
2688
2/4
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 454 times.
✗ Branch 3 not taken.
454 if(!p_igetw(&dummy,f))
2689 {
2690 return qe_invalid;
2691 }
2692
2693
2/2
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 264 times.
454 if(s_version > 16)
2694 {
2695
2/4
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 190 times.
✗ Branch 3 not taken.
190 if(!p_igetl(&compatrule_version,f))
2696 {
2697 return qe_invalid;
2698 }
2699 190 }
2700 454 FFCore.quest_format[vCompatRule] = compatrule_version;
2701
2702 //section size
2703
2/4
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 454 times.
✗ Branch 3 not taken.
454 if(!p_igetl(&dummy,f))
2704 {
2705 return qe_invalid;
2706 }
2707
2708
2/2
✓ Branch 0 taken 264 times.
✓ Branch 1 taken 190 times.
454 if ( s_version < 15 )
2709 {
2710 //finally... section data
2711
2/4
✓ Branch 0 taken 264 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 264 times.
✗ Branch 3 not taken.
264 if(!pfread(quest_rules,QUESTRULES_SIZE,f))
2712 {
2713 return qe_invalid;
2714 }
2715 264 }
2716 else
2717 {
2718
2719
2/4
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 190 times.
✗ Branch 3 not taken.
190 if(!pfread(quest_rules,QUESTRULES_NEW_SIZE,f))
2720 {
2721 return qe_invalid;
2722 }
2723
2724 }
2725 454 }
2726
2727 //{ bunch of compat stuff
2728 7895 memcpy(deprecated_rules, quest_rules, QUESTRULES_NEW_SIZE);
2729
2730
2/2
✓ Branch 0 taken 477 times.
✓ Branch 1 taken 7418 times.
7895 unpack_qrs();
2731
2732
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 395 times.
477 if(s_version<2)
2733 {
2734
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(14,0);
2735
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(27,0);
2736
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(28,0);
2737
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(29,0);
2738
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(30,0);
2739
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(32,0);
2740
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(36,0);
2741
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(49,0);
2742
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(50,0);
2743
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(51,0);
2744
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(68,0);
2745
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(75,0);
2746
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(76,0);
2747
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(98,0);
2748
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(110,0);
2749
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(113,0);
2750
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(116,0);
2751
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(102,0);
2752
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(132,0);
2753 82 }
2754
2755 //Now, do any updates...
2756
3/4
✓ Branch 0 taken 395 times.
✓ Branch 1 taken 82 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 395 times.
477 if((tempheader.zelda_version < 0x211)||((tempheader.zelda_version == 0x211)&&(tempheader.build<18)))
2757 {
2758
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_SMOOTHVERTICALSCROLLING,1);
2759
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_REPLACEOPENDOORS, 1);
2760
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_OLDLENSORDER, 1);
2761
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_NOFAIRYGUYFIRES, 1);
2762
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_TRIGGERSREPEAT, 1);
2763 82 }
2764
2765
3/4
✓ Branch 0 taken 454 times.
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 454 times.
477 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<3)))
2766 {
2767
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_WALLFLIERS,1);
2768 23 }
2769
2770
3/4
✓ Branch 0 taken 454 times.
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 454 times.
477 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<4)))
2771 {
2772
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_NOBOMBPALFLASH,1);
2773 23 }
2774
2775
3/4
✓ Branch 0 taken 454 times.
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 454 times.
477 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<3)))
2776 {
2777
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_NOSCROLLCONTINUE,1);
2778 23 }
2779
2780
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 395 times.
477 if(tempheader.zelda_version <= 0x210)
2781 {
2782
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_ARROWCLIP,1);
2783 82 }
2784
2785
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 418 times.
477 if(tempheader.zelda_version == 0x210)
2786 {
2787
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 set_qr(qr_NOSCROLLCONTINUE, get_qr(qr_CMBCYCLELAYERS));
2788
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 set_qr(qr_CMBCYCLELAYERS, 0);
2789
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 set_qr(qr_CONT_SWORD_TRIGGERS, 1);
2790 59 }
2791
2792
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 395 times.
477 if(tempheader.zelda_version <= 0x210)
2793 {
2794
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_OLDSTYLEWARP,1);
2795
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_210_WARPRETURN,1);
2796 82 }
2797
2798 //might not be correct
2799
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 454 times.
477 if(tempheader.zelda_version < 0x210)
2800 {
2801
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_bit(deprecated_rules, qr_OLDTRIBBLES_DEP,1);
2802
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_OLDTRIBBLES_DEP,1);
2803
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_OLDHOOKSHOTGRAB,1);
2804 23 }
2805
2806
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 395 times.
477 if(tempheader.zelda_version < 0x211)
2807 {
2808
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_WRONG_BRANG_TRAIL_DIR,1);
2809 82 }
2810
2811
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 472 times.
477 if((tempheader.zelda_version == 0x192 && tempheader.build <= 163) || tempheader.zelda_version < 0x192)
2812 {
2813
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 455 times.
477 set_qr(qr_192b163_WARP,1);
2814 22 }
2815
2816
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 49 times.
22 if(tempheader.zelda_version == 0x210)
2817 {
2818
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 set_bit(deprecated_rules, qr_OLDTRIBBLES_DEP, get_qr(qr_DMGCOMBOPRI));
2819
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 set_qr(qr_OLDTRIBBLES_DEP, get_qr(qr_DMGCOMBOPRI));
2820
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 set_qr(qr_DMGCOMBOPRI, 0);
2821 59 }
2822
2823
3/4
✓ Branch 0 taken 395 times.
✓ Branch 1 taken 287 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 395 times.
108 if(tempheader.zelda_version < 0x211 || (tempheader.zelda_version == 0x211 && tempheader.build<15))
2824 {
2825
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 205 times.
287 set_qr(qr_OLDPICKUP,1);
2826 82 }
2827
2828
3/4
✓ Branch 0 taken 395 times.
✓ Branch 1 taken 82 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 395 times.
477 if(tempheader.zelda_version < 0x211 || (tempheader.zelda_version == 0x211 && tempheader.build < 18))
2829 {
2830
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_NOSOLIDDAMAGECOMBOS, 1);
2831
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_ITEMPICKUPSETSBELOW, 1); // broke around build 400
2832 82 }
2833
2834
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 395 times.
477 if(tempheader.zelda_version < 0x250) // version<0x250 checks for beta 18; build was set to 18 prematurely
2835 {
2836
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_HOOKSHOTDOWNBUG, 1);
2837 82 }
2838
2839
4/4
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 272 times.
✓ Branch 2 taken 33 times.
✓ Branch 3 taken 172 times.
477 if(tempheader.zelda_version == 0x250 && tempheader.build == 24) // Annoying...
2840 {
2841
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 set_qr(qr_PEAHATCLOCKVULN, 1);
2842 33 }
2843
2844
4/4
✓ Branch 0 taken 395 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 205 times.
✓ Branch 3 taken 190 times.
477 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 22)) //22 is 2.50.0 RC4. Gotta set the door repair QR... -Dimi
2845 {
2846
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 205 times.
287 set_qr(qr_OLD_DOORREPAIR, 1);
2847 82 }
2848
2849
4/4
✓ Branch 0 taken 395 times.
✓ Branch 1 taken 123 times.
✓ Branch 2 taken 205 times.
✓ Branch 3 taken 190 times.
272 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 20)) //20 is 2.50.0 RC1 and RC2 (cause it didn't get bumped). Okay I'm gonna be honest I have no idea if any 2.50 build was available before RC1, but gonna try and cover my ass here -Dimi
2850 {
2851
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 246 times.
328 set_qr(qr_OLD_SECRETMONEY, 1);
2852 82 }
2853
2854
4/4
✓ Branch 0 taken 395 times.
✓ Branch 1 taken 123 times.
✓ Branch 2 taken 205 times.
✓ Branch 3 taken 190 times.
272 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 28)) //28 is 2.50.1 final. Potion bug might have been used, I dunno. -Dimi
2855 {
2856
2/2
✓ Branch 0 taken 139 times.
✓ Branch 1 taken 189 times.
328 set_qr(qr_OLD_POTION_OR_HC, 1);
2857 139 }
2858
2859
4/4
✓ Branch 0 taken 395 times.
✓ Branch 1 taken 66 times.
✓ Branch 2 taken 205 times.
✓ Branch 3 taken 190 times.
329 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<28))
2860 {
2861
2/2
✓ Branch 0 taken 139 times.
✓ Branch 1 taken 132 times.
271 set_qr(qr_OFFSCREENWEAPONS, 1);
2862 139 }
2863
2864 //Bombchu fix.
2865
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 205 times.
329 if(tempheader.zelda_version == 0x250)
2866 {
2867
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 172 times.
205 if ( tempheader.build == 24 ) //2.50.0
2868 {
2869
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 set_qr(qr_BOMBCHUSUPERBOMB, 1);
2870 33 }
2871
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 199 times.
205 if ( tempheader.build == 28 ) //2.50.1
2872 {
2873
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 set_qr(qr_BOMBCHUSUPERBOMB, 1);
2874 6 }
2875
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 123 times.
205 if ( tempheader.build == 29 ) //2.50.2
2876 {
2877
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_BOMBCHUSUPERBOMB, 0);
2878 82 }
2879
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 205 times.
205 if ( tempheader.build == 30 ) //2.50.3RC1
2880 {
2881 set_qr(qr_BOMBCHUSUPERBOMB, 0);
2882 }
2883 205 }
2884
2885
4/4
✓ Branch 0 taken 395 times.
✓ Branch 1 taken 66 times.
✓ Branch 2 taken 205 times.
✓ Branch 3 taken 190 times.
329 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<29))
2886 {
2887 // qr_OFFSETEWPNCOLLISIONFIX
2888 // All 'official' quests need this disabled.
2889 // All 2.10 and lower quests need this enabled to preseve compatability.
2890 // All 2.11 - 2.5.1 quests should have it set also, due to a bug in about half of all the betas.
2891
2892 //~Gleeok
2893
2/2
✓ Branch 0 taken 145 times.
✓ Branch 1 taken 126 times.
271 set_qr(qr_OFFSETEWPNCOLLISIONFIX, 1); //This has to be set!!!!
2894
2895 // Broke in build 695
2896
3/4
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 63 times.
✗ Branch 3 not taken.
145 if(tempheader.zelda_version>=0x211 && tempheader.build>=18)
2897
1/2
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
63 set_qr(qr_BROKENSTATUES, 1);
2898 145 }
2899
11/14
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 459 times.
✓ Branch 2 taken 454 times.
✓ Branch 3 taken 5 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 578 times.
✓ Branch 7 taken 5 times.
✓ Branch 8 taken 578 times.
✓ Branch 9 taken 5 times.
✓ Branch 10 taken 22 times.
✓ Branch 11 taken 561 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
335 if (tempheader.zelda_version <= 0x190 || (tempheader.zelda_version == 0x192 && std::string(tempheader.title).starts_with("Zelda 3000\0")))
2900 {
2901
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 set_qr(qr_COPIED_SWIM_SPRITES, 1);
2902 22 }
2903
8/8
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 378 times.
✓ Branch 2 taken 288 times.
✓ Branch 3 taken 90 times.
✓ Branch 4 taken 206 times.
✓ Branch 5 taken 82 times.
✓ Branch 6 taken 190 times.
✓ Branch 7 taken 16 times.
583 if ( (tempheader.zelda_version == 0x250 && tempheader.build < 33) || tempheader.zelda_version == 0x254 || tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x255 && tempheader.build < 50) )
2904 {
2905
2/2
✓ Branch 0 taken 271 times.
✓ Branch 1 taken 296 times.
567 set_qr(qr_OLD_SLASHNEXT_SECRETS, 1);
2906 271 }
2907
2908
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 205 times.
287 if ( (tempheader.zelda_version < 0x211) ) //2.10 water and ladder interaction
2909 {
2910
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_OLD_210_WATER, 1);
2911 82 }
2912
2913
4/6
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 133 times.
✓ Branch 2 taken 190 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 190 times.
287 if ( (tempheader.zelda_version < 0x255 ) || (tempheader.zelda_version == 0x255 && tempheader.build < 51 ) ) //2.10 water and ladder interaction
2914 {
2915
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 154 times.
133 set_qr(qr_STEP_IS_FLOAT,0);
2916 287 }
2917
2918
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 395 times.
477 if ( tempheader.zelda_version < 0x250 )
2919 {
2920
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_8WAY_SHOT_SFX_DEP, 1);
2921 82 }
2922
2923
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 395 times.
477 if(s_version < 3)
2924 {
2925
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_HOLDNOSTOPMUSIC, 1);
2926
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_CAVEEXITNOSTOPMUSIC, 1);
2927 82 }
2928
2929
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 395 times.
477 if(s_version<4)
2930 {
2931
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(10,0);
2932 82 }
2933
2934
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 395 times.
477 if(s_version<5)
2935 {
2936
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(27,0);
2937 82 }
2938
2939
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 395 times.
477 if(s_version<6)
2940 {
2941
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(46,0);
2942 82 }
2943
2944
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 395 times.
477 if(s_version<7) // January 2008
2945 {
2946
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_HEARTSREQUIREDFIX,0);
2947
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_PUSHBLOCKCSETFIX,1);
2948 82 }
2949
2950
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 395 times.
477 if(s_version<8)
2951 {
2952
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(12, 0);
2953 82 }
2954 else
2955 {
2956
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 set_bit(deprecated_rules, 12, 0);
2957 }
2958
2959
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 395 times.
477 if(s_version<9) // October 2008
2960 {
2961
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_NOROPE2FLASH_DEP,0);
2962
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_NOBUBBLEFLASH_DEP,0);
2963
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_GHINI2BLINK_DEP,0);
2964
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_PHANTOMGHINI2_DEP,0);
2965 82 }
2966
2967
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 395 times.
477 if(s_version<10) // December 2008
2968 {
2969
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_NOCLOCKS_DEP,0);
2970
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_ALLOW10RUPEEDROPS_DEP,0);
2971 82 }
2972
2973
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 395 times.
477 if(s_version<11) // April 2009
2974 {
2975
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_SLOWENEMYANIM_DEP,0);
2976 82 }
2977
2978 // This served no purpose.
2979 // if(s_version<12) // December 2009
2980 // {
2981 // set_qr(qr_BRKBLSHLDS_DEP,0);
2982 // set_qr(qr_OLDTRIBBLES_DEP,0);
2983 // }
2984
2985 //if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 24))
2986
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 395 times.
477 if(s_version < 13)
2987 {
2988
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_SHOPCHEAT, 1);
2989 82 }
2990
2991 // Not entirely sure this is the best place for this...
2992 //2.50.2 bitmap offset fix
2993 477 memset(extra_rules, 0, EXTRARULES_SIZE);
2994
4/4
✓ Branch 0 taken 395 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 205 times.
✓ Branch 3 taken 190 times.
477 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<29))
2995 {
2996
2/2
✓ Branch 0 taken 145 times.
✓ Branch 1 taken 142 times.
287 set_er(er_BITMAPOFFSET, 1);
2997
1/2
✓ Branch 0 taken 145 times.
✗ Branch 1 not taken.
145 set_qr(qr_BITMAPOFFSETFIX, 1);
2998 145 }
2999 //required because quest templates also used this bit, although
3000 //it never did anything, before. -Z
3001
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 130 times.
335 if ( tempheader.zelda_version == 0x250 )
3002 {
3003
5/6
✓ Branch 0 taken 123 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 123 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16 times.
✓ Branch 5 taken 107 times.
205 if( tempheader.build == 29 || tempheader.build == 30 || tempheader.build == 31 )
3004 {
3005
1/2
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
98 set_er(er_BITMAPOFFSET, 0);
3006
1/2
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
98 set_qr(qr_BITMAPOFFSETFIX, 0);
3007 98 }
3008 205 }
3009
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 335 times.
335 if ( tempheader.zelda_version == 0x254 )
3010 {
3011 set_er(er_BITMAPOFFSET, 0);
3012 set_qr(qr_BITMAPOFFSETFIX, 0);
3013 }
3014
3/4
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 145 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 190 times.
335 if ( tempheader.zelda_version == 0x255 && tempheader.build < 42 ) //QR was added to 255 in this build.
3015 {
3016 set_er(er_BITMAPOFFSET, 0);
3017 set_qr(qr_BITMAPOFFSETFIX, 0);
3018 }
3019 //optimise fast drawing for older versions.
3020
3/4
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 145 times.
✓ Branch 2 taken 190 times.
✗ Branch 3 not taken.
335 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 42) )
3021 {
3022
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 90 times.
335 set_qr(qr_OLDSPRITEDRAWS, 1);
3023 287 }
3024 //Old eweapon->Parent (was added in 2.54, Alpha 19)
3025 //The change was made in build 43, but I'm setting this to < 42, because quests made in 42 would benefit from this change, and
3026 //older quests can set the rule by hand. We need a new qst.dat again.
3027
4/4
✓ Branch 0 taken 477 times.
✓ Branch 1 taken 190 times.
✓ Branch 2 taken 190 times.
✓ Branch 3 taken 287 times.
287 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 42) )
3028 {
3029
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 380 times.
380 set_qr(qr_OLDEWPNPARENT, 1);
3030 }
3031
4/4
✓ Branch 0 taken 477 times.
✓ Branch 1 taken 190 times.
✓ Branch 2 taken 190 times.
✓ Branch 3 taken 287 times.
287 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 44) )
3032 {
3033
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 380 times.
380 set_qr(qr_OLDCREATEBITMAP_ARGS, 1);
3034 }
3035
4/4
✓ Branch 0 taken 477 times.
✓ Branch 1 taken 190 times.
✓ Branch 2 taken 190 times.
✓ Branch 3 taken 287 times.
287 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 45) )
3036 {
3037
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 380 times.
380 set_qr(qr_OLDQUESTMISC, 1);
3038 }
3039
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if ( tempheader.zelda_version < 0x254 )
3040 {
3041
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLDCREATEBITMAP_ARGS, 0);
3042
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLDEWPNPARENT, 0);
3043
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLDQUESTMISC, 0);
3044 287 }
3045
3046 //item scripts continue to run
3047
3/4
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 133 times.
✓ Branch 2 taken 190 times.
✗ Branch 3 not taken.
287 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 44) )
3048 {
3049
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 36 times.
323 set_qr(qr_ITEMSCRIPTSKEEPRUNNING, 0);
3050
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_SCRIPTSRUNINHEROSTEPFORWARD, 0);
3051
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_FIXSCRIPTSDURINGSCROLLING, 0);
3052
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_SCRIPTDRAWSINWARPS, 0);
3053
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_DYINGENEMYESDONTHURTHERO, 0);
3054
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OUTOFBOUNDSENEMIES, 0);
3055
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_SPRITEXY_IS_FLOAT, 0);
3056 287 }
3057
3058
3/4
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 133 times.
✓ Branch 2 taken 190 times.
✗ Branch 3 not taken.
287 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 46) )
3059 {
3060
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 36 times.
323 set_qr(qr_CLEARINITDONSCRIPTCHANGE, 1);
3061 287 }
3062
3/4
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 133 times.
✓ Branch 2 taken 190 times.
✗ Branch 3 not taken.
287 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 46) )
3063 {
3064
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 36 times.
323 set_qr(qr_TRACESCRIPTIDS, 0);
3065
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES, 1);
3066
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_PARSER_BOOL_TRUE_DECIMAL, 1);
3067
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_PARSER_250DIVISION,1);
3068
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_PARSER_BOOL_TRUE_DECIMAL,1);
3069
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_PARSER_TRUE_INT_SIZE,0);
3070
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_PARSER_FORCE_INLINE,0);
3071
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_PARSER_BINARY_32BIT,0);
3072
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 278 times.
287 if ( get_qr(qr_SELECTAWPN) )
3073 {
3074
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 set_qr(qr_NO_L_R_BUTTON_INVENTORY_SWAP,1);
3075 //In < 2.55a27, if you had an A+B subscreen, L and R didn't shift through inventory.
3076 //Now they **do**, unless you disable that behaviour.
3077 //For the sake of compatibility, old quests with the A+B subscreen rule enabed
3078 //now enable the disable L/R item swap on load.
3079 9 }
3080
3081 287 }
3082
3/4
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 133 times.
✓ Branch 2 taken 190 times.
✗ Branch 3 not taken.
287 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 47) )
3083 {
3084 //Compatibility: Setting the hero's action to rafting was previously disallowed, though legal for scripts to attempt.
3085
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 36 times.
323 set_qr(qr_DISALLOW_SETTING_RAFTING, 1);
3086 //Compatibility: The calculation for when to loop an animation did not factor in ASkipY correctly, resulting in
3087 //animations ending earlier than they should.
3088
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_BROKEN_ASKIP_Y_FRAMES, 1);
3089 //Enemies would ignore solidity on the top half of combos
3090
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY, 1);
3091 //Ceiling collison was a bit wonky, including hitting your head before you are near the ceiling or clipping into it slightly.
3092
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLD_SIDEVIEW_CEILING_COLLISON, 1);
3093 //If an itemdata had a 'frames' of 0, items created of that data would ignore all changes to 'frames'
3094
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_0AFRAME_ITEMS_IGNORE_AFRAME_CHANGES, 1);
3095 //Collision used some odd calculations before, and enemies could not be hit back into the top row or left column
3096
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION, 1);
3097 287 }
3098
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if ( tempheader.zelda_version < 0x255 )
3099 {
3100
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_NOFFCWAITDRAW, 1);
3101
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_NOITEMWAITDRAW, 1);
3102
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_SETENEMYWEAPONSPRITESONWPNCHANGE, 1);
3103
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLD_INIT_SCRIPT_TIMING, 1);
3104 //set_qr(qr_DO_NOT_DEALLOCATE_INIT_AND_SAVELOAD_ARRAYS, 1);
3105 287 }
3106
3/4
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 133 times.
✓ Branch 2 taken 190 times.
✗ Branch 3 not taken.
287 if ( tempheader.zelda_version < 0x255 || ( tempheader.zelda_version == 0x255 && tempheader.build < 48 ) )
3107 {
3108
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 36 times.
323 set_qr(qr_SETENEMYWEAPONSPRITESONWPNCHANGE, 1);
3109 287 }
3110
3/4
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 133 times.
✓ Branch 2 taken 190 times.
✗ Branch 3 not taken.
287 if( tempheader.zelda_version < 0x255 || ( tempheader.zelda_version == 0x255 && tempheader.build < 52 ) )
3111 {
3112
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 36 times.
323 set_qr(qr_OLD_PRINTF_ARGS, 1);
3113 287 }
3114
3115
3116
3/4
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 133 times.
✓ Branch 2 taken 190 times.
✗ Branch 3 not taken.
287 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 54) )
3117 {
3118
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 36 times.
323 set_qr(qr_BROKEN_RING_POWER, 1);
3119 287 }
3120
3/4
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 133 times.
✓ Branch 2 taken 190 times.
✗ Branch 3 not taken.
287 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 56) )
3121 {
3122
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 36 times.
323 set_qr(qr_NO_OVERWORLD_MAP_CHARTING, 1);
3123 287 }
3124
5/6
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 133 times.
✓ Branch 2 taken 190 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 154 times.
✓ Branch 5 taken 36 times.
287 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 57) )
3125 {
3126
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_DUNGEONS_USE_CLASSIC_CHARTING, 1);
3127 287 }
3128
3/4
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 133 times.
✓ Branch 2 taken 190 times.
✗ Branch 3 not taken.
323 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 58) )
3129 {
3130 //Rule used to be 'qr_SETXYBUTTONITEMS', now split.
3131
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 287 times.
323 if(get_qr(qr_SET_XBUTTON_ITEMS))
3132 set_qr(qr_SET_YBUTTON_ITEMS,1);
3133 287 }
3134
3/4
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 133 times.
✓ Branch 2 taken 190 times.
✗ Branch 3 not taken.
287 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 59) )
3135 {
3136
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 36 times.
323 set_qr(qr_ALLOW_EDITING_COMBO_0,1);
3137 287 }
3138
3/4
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 133 times.
✓ Branch 2 taken 190 times.
✗ Branch 3 not taken.
287 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 60) )
3139 {
3140
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 36 times.
323 set_qr(qr_OLD_CHEST_COLLISION,1);
3141 287 }
3142
3143
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if ( tempheader.zelda_version < 0x254 )
3144 {
3145
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_250WRITEEDEFSCRIPT, 1);
3146 287 }
3147 //Sideview spikes in 2.50.0
3148
4/4
✓ Branch 0 taken 395 times.
✓ Branch 1 taken 116 times.
✓ Branch 2 taken 205 times.
✓ Branch 3 taken 190 times.
287 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<27)) //2.50.1RC3
3149 {
3150
2/2
✓ Branch 0 taken 139 times.
✓ Branch 1 taken 182 times.
321 set_qr(qr_OLDSIDEVIEWSPIKES, 1);
3151 139 }
3152 //more 2.50 fixes -Z
3153
4/4
✓ Branch 0 taken 395 times.
✓ Branch 1 taken 66 times.
✓ Branch 2 taken 205 times.
✓ Branch 3 taken 190 times.
329 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<31))
3154 {
3155
2/2
✓ Branch 0 taken 227 times.
✓ Branch 1 taken 74 times.
271 set_qr(qr_MELEEMAGICCOST, 0);
3156
1/2
✓ Branch 0 taken 227 times.
✗ Branch 1 not taken.
227 set_qr(qr_GANONINTRO, 0); //This will get flipped later on in the compatrule 11 check. That's why it's turning it off.
3157
1/2
✓ Branch 0 taken 227 times.
✗ Branch 1 not taken.
227 set_qr(qr_OLDMIRRORCOMBOS, 1);
3158
1/2
✓ Branch 0 taken 227 times.
✗ Branch 1 not taken.
227 set_qr(qr_BROKENBOOKCOST, 1);
3159
1/2
✓ Branch 0 taken 227 times.
✗ Branch 1 not taken.
227 set_qr(qr_BROKENCHARINTDRAWING, 1);
3160
3161 227 }
3162
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 417 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
417 if(tempheader.zelda_version == 0x254 && tempheader.build<41)
3163 {
3164 //set_qr(qr_MELEEMAGICCOST, get_er(er_MAGICCOSTSWORD));
3165 set_qr(qr_MELEEMAGICCOST, 1);
3166 }
3167
3168
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 394 times.
417 if(tempheader.zelda_version < 0x193)
3169 {
3170
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_SHORTDGNWALK, 1);
3171 23 }
3172
3173
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 130 times.
417 if(tempheader.zelda_version < 0x255)
3174 {
3175
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLDINFMAGIC, 1);
3176 287 }
3177
3178
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 335 times.
417 if((tempheader.zelda_version < 0x250)) //2.10 and earlier allowed the triforce to Warp Hero out of Item Cellars in Dungeons. -Z (15th March, 2019 )
3179 {
3180
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_SIDEVIEWTRIFORCECELLAR,1);
3181 82 }
3182
3183
3/4
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 227 times.
✓ Branch 2 taken 190 times.
✗ Branch 3 not taken.
417 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 47) )
3184 {
3185
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 130 times.
417 set_qr(qr_OLD_F6,1);
3186 287 }
3187
3/4
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 133 times.
✓ Branch 2 taken 190 times.
✗ Branch 3 not taken.
287 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 49) )
3188 {
3189
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 36 times.
323 set_qr(qr_NO_OVERWRITING_HOPPING,1);
3190 287 }
3191
3/4
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 133 times.
✓ Branch 2 taken 190 times.
✗ Branch 3 not taken.
287 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 50) )
3192 {
3193
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 36 times.
323 set_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT,1);
3194 287 }
3195
3/4
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 133 times.
✓ Branch 2 taken 190 times.
✗ Branch 3 not taken.
287 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 53) )
3196 {
3197
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 36 times.
323 set_qr(qr_BROKEN_OVERWORLD_MINIMAP,1);
3198 287 }
3199 //}
3200
3201
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 1) //Enemies->Secret only affects flag 16-31
3202
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_ENEMIES_SECRET_ONLY_16_31,1);
3203
3204
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 2) //Old CSet2 Handling
3205
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLDCS2,1);
3206
3207
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 3) //Hardcoded Shadow/Spawn/Death anim frames
3208
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_HARDCODED_ENEMY_ANIMS,1);
3209
3210
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 4) //Hardcoded Shadow/Spawn/Death anim frames
3211
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLD_ITEMDATA_SCRIPT_TIMING,1);
3212
3213
3/4
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 205 times.
✓ Branch 3 taken 82 times.
287 if(compatrule_version < 5 && tempheader.zelda_version >= 0x250) //Hardcoded Shadow/Spawn/Death anim frames
3214
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 set_qr(qr_NO_LANMOLA_RINGLEADER,1);
3215
3216
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 6) //Step->Secret (Temp) only affects flag 16-31
3217
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_STEPTEMP_SECRET_ONLY_16_31,1);
3218
3219
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 7) //'Hit All Triggers->Perm Secret' doesn't trigger temp secrets
3220
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_ALLTRIG_PERMSEC_NO_TEMP,1);
3221
3222
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 8) //Hardcoded LItem/Bomb/Clock/Magic Tile Mods
3223
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_HARDCODED_LITEM_LTMS,1);
3224
3225
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 9)
3226 {
3227 //Hardcoded BS Patras
3228
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_HARDCODED_BS_PATRA,1);
3229 //Hardcoded Patra Inner Eye offsets
3230
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_PATRAS_USE_HARDCODED_OFFSETS,1);
3231 //Broken 'Big enemy' animation style
3232
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_BROKEN_BIG_ENEMY_ANIMATION,1);
3233 //Broken Attribute 31/32
3234
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_BROKEN_ATTRIBUTE_31_32,1);
3235 287 }
3236
3237
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 10) //Shared candle use limits
3238
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_CANDLES_SHARED_LIMIT,1);
3239
3240
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 11) //No cross-screen return points
3241
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLD_RESPAWN_POINTS,1);
3242
3243
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 12)
3244 {
3245 //Old fire trail duration
3246
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLD_FLAMETRAIL_DURATION,1);
3247 //Old Intro String in Ganon Room Behavior
3248
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 287 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
287 if(get_qr(qr_GANONINTRO)) set_qr(qr_GANONINTRO,0);
3249
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 else set_qr(qr_GANONINTRO,1);
3250 287 }
3251
3252
2/4
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 287 times.
287 if(compatrule_version < 13 && tempheader.zelda_version >= 0x255) //ANone doesn't reset to originaltile
3253 set_qr(qr_ANONE_NOANIM,1);
3254
3255
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 14) //Old Bridge Combo Behavior
3256
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLD_BRIDGE_COMBOS,1);
3257
3258
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 15) //Broken Z3 Animation
3259
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_BROKEN_Z3_ANIMATION,1);
3260
3261
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 16) //Old Enemy Tile Behavior with Animation (None) Enemies
3262
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLD_TILE_INITIALIZATION,1);
3263
3264
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 287 times.
287 if(compatrule_version < 17)
3265 {
3266 //Old Quake/DrawYOffset behavior
3267 //set_qr(qr_OLD_DRAWOFFSET,1);
3268 //I'm leaving this commented cause I doubt it'll break anything and I think the bugfix might be appreciated in older versions.
3269 //On the offchance that it *does* break old quests, fixing it is as simple as uncommenting the set_bit above.
3270 287 }
3271
3272
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 18)
3273 {
3274 //Broken DrawScreen Derivative Functions
3275
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_BROKEN_DRAWSCREEN_FUNCTIONS,1);
3276 //Scrolling Cancels Charge
3277
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_SCROLLING_KILLS_CHARGE,1);
3278 287 }
3279
3280
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 19) //Broken Enemy Item Carrying with Large Enemies
3281
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_BROKEN_ITEM_CARRYING,1);
3282
3283
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 20)
3284
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_CUSTOMWEAPON_IGNORE_COST,1);
3285
3286
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 21)
3287 {
3288
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_LEEVERS_DONT_OBEY_STUN,1);
3289
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_GANON_CANT_SPAWN_ON_CONTINUE,1);
3290
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_WIZZROBES_DONT_OBEY_STUN,1);
3291
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLD_BUG_NET,1);
3292
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_MANHANDLA_BLOCK_SFX,1);
3293 287 }
3294
3295
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 22)
3296
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_BROKEN_KEEPOLD_FLAG,1);
3297
3298
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 23)
3299
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLD_HALF_MAGIC,1);
3300
3301
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 24)
3302 {
3303
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_WARPS_RESTART_DMAPSCRIPT,1);
3304
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_DMAP_0_CONTINUE_BUG,1);
3305 287 }
3306
3307
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 287 times.
287 if(compatrule_version < 25)
3308 {
3309
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 287 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
287 if (get_qr(qr_OLD_FAIRY_LIMIT)) set_qr(qr_OLD_FAIRY_LIMIT,0);
3310
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 else set_qr(qr_OLD_FAIRY_LIMIT,1);
3311
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLD_SCRIPTED_KNOCKBACK,1);
3312 287 }
3313
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 26)
3314 {
3315
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLD_KEESE_Z_AXIS,1);
3316
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_POLVIRE_NO_SHADOW,1);
3317
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_SUBSCR_OLD_SELECTOR,1);
3318 287 }
3319
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 287 times.
287 if(compatrule_version < 27) //Noticed some junk data in the QR array...
3320 {
3321
2/2
✓ Branch 0 taken 86387 times.
✓ Branch 1 taken 287 times.
86674 for(auto q = qr_POLVIRE_NO_SHADOW+1; q < qr_PARSER_250DIVISION; ++q)
3322
1/2
✓ Branch 0 taken 86387 times.
✗ Branch 1 not taken.
86387 set_qr(q,0);
3323
2/2
✓ Branch 0 taken 1722 times.
✓ Branch 1 taken 287 times.
2009 for(auto q = qr_COMBODATA_INITD_MULT_TENK+1; q < qr_MAX; ++q)
3324
1/2
✓ Branch 0 taken 1722 times.
✗ Branch 1 not taken.
1722 set_qr(q,0);
3325 //This should nuke any remaining junk data... not sure if it affected anything previous. -Em
3326 287 }
3327
2/2
✓ Branch 0 taken 292 times.
✓ Branch 1 taken 5 times.
287 if(compatrule_version < 28)
3328
1/2
✓ Branch 0 taken 292 times.
✗ Branch 1 not taken.
292 set_qr(qr_SUBSCR_BACKWARDS_ID_ORDER,1);
3329
2/2
✓ Branch 0 taken 292 times.
✓ Branch 1 taken 5 times.
297 if(compatrule_version < 29)
3330
1/2
✓ Branch 0 taken 292 times.
✗ Branch 1 not taken.
292 set_qr(qr_OLD_LOCKBLOCK_COLLISION,1);
3331
2/2
✓ Branch 0 taken 292 times.
✓ Branch 1 taken 5 times.
297 if(compatrule_version < 30)
3332 {
3333
1/2
✓ Branch 0 taken 292 times.
✗ Branch 1 not taken.
292 set_qr(qr_DECO_2_YOFFSET,1);
3334
1/2
✓ Branch 0 taken 292 times.
✗ Branch 1 not taken.
292 set_qr(qr_SCREENSTATE_80s_BUG,1);
3335 292 }
3336
2/2
✓ Branch 0 taken 292 times.
✓ Branch 1 taken 5 times.
297 if(compatrule_version < 31)
3337 {
3338
1/2
✓ Branch 0 taken 292 times.
✗ Branch 1 not taken.
292 set_qr(qr_GOHMA_UNDAMAGED_BUG,1);
3339
1/2
✓ Branch 0 taken 292 times.
✗ Branch 1 not taken.
292 set_qr(qr_FFCPRELOAD_BUGGED_LOAD,1);
3340 292 }
3341
2/2
✓ Branch 0 taken 292 times.
✓ Branch 1 taken 5 times.
297 if(compatrule_version < 32)
3342
1/2
✓ Branch 0 taken 292 times.
✗ Branch 1 not taken.
292 set_qr(qr_BROKEN_GETPIXEL_VALUE,1);
3343
2/2
✓ Branch 0 taken 292 times.
✓ Branch 1 taken 5 times.
297 if(compatrule_version < 33)
3344
1/2
✓ Branch 0 taken 292 times.
✗ Branch 1 not taken.
292 set_qr(qr_NO_LIFT_SPRITE,1);
3345
2/2
✓ Branch 0 taken 292 times.
✓ Branch 1 taken 5 times.
297 if(compatrule_version < 34)
3346 {
3347
1/2
✓ Branch 0 taken 292 times.
✗ Branch 1 not taken.
292 set_qr(qr_OLD_SIDEVIEW_LANDING_CODE,1);
3348
1/2
✓ Branch 0 taken 292 times.
✗ Branch 1 not taken.
292 set_qr(qr_OLD_FFC_SPEED_CAP,1);
3349
1/2
✓ Branch 0 taken 292 times.
✗ Branch 1 not taken.
292 set_qr(qr_OLD_FFC_FUNCTIONALITY,1);
3350
1/2
✓ Branch 0 taken 292 times.
✗ Branch 1 not taken.
292 set_qr(qr_OLD_WIZZROBE_SUBMERGING,1);
3351 292 }
3352
2/2
✓ Branch 0 taken 294 times.
✓ Branch 1 taken 3 times.
297 if(compatrule_version < 35)
3353 {
3354
1/2
✓ Branch 0 taken 294 times.
✗ Branch 1 not taken.
294 set_qr(qr_ZS_NO_NEG_ARRAY,1);
3355
1/2
✓ Branch 0 taken 294 times.
✗ Branch 1 not taken.
294 set_qr(qr_BROKEN_INPUT_DOWN_STATE,1);
3356 294 }
3357
2/2
✓ Branch 0 taken 294 times.
✓ Branch 1 taken 3 times.
297 if(compatrule_version < 36)
3358
1/2
✓ Branch 0 taken 294 times.
✗ Branch 1 not taken.
294 set_qr(qr_OLD_SHALLOW_SFX,1);
3359
2/2
✓ Branch 0 taken 298 times.
✓ Branch 1 taken 3 times.
297 if(compatrule_version < 37)
3360
1/2
✓ Branch 0 taken 298 times.
✗ Branch 1 not taken.
298 set_qr(qr_SPARKLES_INHERIT_PROPERTIES,1);
3361
2/2
✓ Branch 0 taken 298 times.
✓ Branch 1 taken 3 times.
301 if(compatrule_version < 38)
3362
1/2
✓ Branch 0 taken 298 times.
✗ Branch 1 not taken.
298 set_qr(qr_BUGGED_LAYERED_FLAGS,1);
3363
2/2
✓ Branch 0 taken 298 times.
✓ Branch 1 taken 3 times.
301 if(compatrule_version < 39)
3364
1/2
✓ Branch 0 taken 298 times.
✗ Branch 1 not taken.
298 set_qr(qr_HARDCODED_FFC_BUSH_DROPS,1);
3365
2/2
✓ Branch 0 taken 298 times.
✓ Branch 1 taken 3 times.
301 if(compatrule_version < 40)
3366
1/2
✓ Branch 0 taken 298 times.
✗ Branch 1 not taken.
298 set_qr(qr_MOVINGBLOCK_FAKE_SOLID,1);
3367
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 5 times.
301 if(compatrule_version < 41)
3368
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 set_qr(qr_BROKENHITBY,1);
3369
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 5 times.
305 if(compatrule_version < 42)
3370
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 set_qr(qr_BROKEN_MOVING_BOMBS,1);
3371
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 5 times.
305 if(compatrule_version < 43)
3372
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 set_qr(qr_OLD_BOMB_HITBOXES,1);
3373
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 5 times.
305 if(compatrule_version < 44)
3374
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 set_qr(qr_SCROLLWARP_NO_RESET_FRAME,1);
3375
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 5 times.
305 if(compatrule_version < 45)
3376
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 set_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME,1);
3377
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 5 times.
305 if(compatrule_version < 46)
3378
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 set_qr(qr_BROKEN_RAFT_SCROLL,1);
3379
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 7 times.
305 if(compatrule_version < 47)
3380 {
3381
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 set_qr(qr_SENSITIVE_SOLID_DAMAGE,1);
3382
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 set_qr(qr_OLD_CONVEYOR_COLLISION,1);
3383 304 }
3384
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 7 times.
311 if(compatrule_version < 48)
3385
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 set_qr(qr_OLD_GUY_HANDLING,1);
3386
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 7 times.
311 if(compatrule_version < 49)
3387
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 set_qr(qr_FAIRY_FLAG_COMPAT,1);
3388
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 7 times.
311 if(compatrule_version < 50)
3389
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 set_qr(qr_OLD_LENS_LAYEREFFECT,1);
3390
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 7 times.
311 if(compatrule_version < 51)
3391
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 set_qr(qr_PUSHBLOCK_SPRITE_LAYER,1);
3392
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 7 times.
311 if (compatrule_version < 52)
3393
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 set_qr(qr_OLD_SCRIPT_VOLUME, 1);
3394
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 7 times.
311 if(compatrule_version < 53)
3395 {
3396
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 set_qr(qr_OLD_SUBSCR,1);
3397
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 set_qr(qr_ITM_0_INVIS_ON_BTNS,1);
3398
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 set_qr(qr_OLD_GAUGE_TILE_LAYOUT,1);
3399 304 }
3400
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 7 times.
311 if(compatrule_version < 54)
3401
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 set_qr(qr_WALKTHROUGHWALL_NO_DOORSTATE,1);
3402
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 7 times.
311 if(compatrule_version < 55)
3403
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 set_qr(qr_SPOTLIGHT_IGNR_SOLIDOBJ,1);
3404
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 7 times.
311 if(compatrule_version < 56)
3405
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 set_qr(qr_BROKEN_LIGHTBEAM_HITBOX,1);
3406
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 7 times.
311 if(compatrule_version < 57)
3407
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 set_qr(qr_BROKEN_SWORD_SPIN_TRIGGERS,1);
3408
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 7 times.
311 if(compatrule_version < 58)
3409
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 set_qr(qr_OLD_DMAP_INTRO_STRINGS,1);
3410
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 7 times.
311 if(compatrule_version < 59)
3411
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 set_qr(qr_SCRIPT_CONTHP_IS_HEARTS,1);
3412
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 7 times.
311 if(compatrule_version < 60)
3413
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 set_qr(qr_SEPARATE_BOMBABLE_TAPPING_SFX,1);
3414
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 7 times.
311 if(compatrule_version < 61)
3415
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 set_qr(qr_BROKEN_BOMB_AMMO_COSTS,1);
3416
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 7 times.
311 if(compatrule_version < 62)
3417
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 set_qr(qr_OLD_BROKEN_WARPEX_MUSIC,1);
3418
2/2
✓ Branch 0 taken 305 times.
✓ Branch 1 taken 6 times.
311 if(compatrule_version < 63)
3419 {
3420
1/2
✓ Branch 0 taken 305 times.
✗ Branch 1 not taken.
305 set_qr(qr_BROKEN_LIFTSWIM,1);
3421
1/2
✓ Branch 0 taken 305 times.
✗ Branch 1 not taken.
305 set_qr(qr_BROKEN_GENERIC_PUSHBLOCK_LOCKING,1);
3422 305 }
3423
2/2
✓ Branch 0 taken 305 times.
✓ Branch 1 taken 6 times.
311 if(compatrule_version < 64)
3424
1/2
✓ Branch 0 taken 305 times.
✗ Branch 1 not taken.
305 set_qr(qr_BROKEN_FLAME_ARROW_REFLECTING,1);
3425
2/2
✓ Branch 0 taken 330 times.
✓ Branch 1 taken 21 times.
311 if(compatrule_version < 65)
3426
1/2
✓ Branch 0 taken 330 times.
✗ Branch 1 not taken.
330 set_qr(qr_BROKEN_SIDEVIEW_SPRITE_JUMP,1);
3427
2/2
✓ Branch 0 taken 332 times.
✓ Branch 1 taken 19 times.
351 if(compatrule_version < 66)
3428
1/2
✓ Branch 0 taken 332 times.
✗ Branch 1 not taken.
332 set_qr(qr_NEWDARK_TRANS_STACKING,1);
3429
2/2
✓ Branch 0 taken 332 times.
✓ Branch 1 taken 19 times.
351 if(compatrule_version < 67)
3430
1/2
✓ Branch 0 taken 332 times.
✗ Branch 1 not taken.
332 set_qr(qr_OLD_HERO_WARP_RETSQUARE,1);
3431
2/2
✓ Branch 0 taken 332 times.
✓ Branch 1 taken 19 times.
351 if(compatrule_version < 68)
3432
1/2
✓ Branch 0 taken 332 times.
✗ Branch 1 not taken.
332 set_qr(qr_SCRIPTS_6_BIT_COLOR,1);
3433
2/2
✓ Branch 0 taken 332 times.
✓ Branch 1 taken 19 times.
351 if(compatrule_version < 69)
3434
1/2
✓ Branch 0 taken 332 times.
✗ Branch 1 not taken.
332 set_qr(qr_SETENEMYWEAPONSOUNDSONWPNCHANGE, 1);
3435
2/2
✓ Branch 0 taken 332 times.
✓ Branch 1 taken 19 times.
351 if (compatrule_version < 70)
3436
1/2
✓ Branch 0 taken 332 times.
✗ Branch 1 not taken.
332 set_qr(qr_BROKEN_CONVEYORS, 1);
3437
2/2
✓ Branch 0 taken 332 times.
✓ Branch 1 taken 19 times.
351 if (compatrule_version < 71)
3438
1/2
✓ Branch 0 taken 332 times.
✗ Branch 1 not taken.
332 set_qr(qr_BROKEN_PUSHBLOCK_TOP_HALF_SOLIDS, 1);
3439
2/2
✓ Branch 0 taken 332 times.
✓ Branch 1 taken 19 times.
351 if (compatrule_version < 72)
3440
1/2
✓ Branch 0 taken 332 times.
✗ Branch 1 not taken.
332 set_qr(qr_BROKEN_PUSHBLOCK_FLAG_CLONING, 1);
3441
2/2
✓ Branch 0 taken 332 times.
✓ Branch 1 taken 19 times.
351 if (compatrule_version < 73)
3442 {
3443
1/2
✓ Branch 0 taken 332 times.
✗ Branch 1 not taken.
332 set_qr(qr_OLD_LANDING_SFX, 1);
3444
1/2
✓ Branch 0 taken 332 times.
✗ Branch 1 not taken.
332 set_qr(qr_FIRE_LEVEL_TRIGGERS_ARENT_WEAPONS, 1);
3445 332 }
3446
5/6
✓ Branch 0 taken 332 times.
✓ Branch 1 taken 19 times.
✓ Branch 2 taken 331 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 331 times.
✗ Branch 5 not taken.
351 if (compatrule_version < 74 && (tempheader.version_major >= 3 || tempheader.compareVer(2, 55, 9) < 0))
3447
2/2
✓ Branch 0 taken 332 times.
✓ Branch 1 taken 331 times.
1 set_qr(qr_BROKEN_SCRIPTS_SCROLLING_HERO_POSITION, 1);
3448
5/6
✓ Branch 0 taken 332 times.
✓ Branch 1 taken 350 times.
✓ Branch 2 taken 331 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 331 times.
✗ Branch 5 not taken.
682 if (compatrule_version < 75 && (tempheader.version_major >= 3 || tempheader.compareVer(2, 55, 10) < 0))
3449
2/2
✓ Branch 0 taken 332 times.
✓ Branch 1 taken 331 times.
1 set_qr(qr_BROKEN_SCRIPTS_BITMAP_DRAW_ORIGIN, 1);
3450
5/6
✓ Branch 0 taken 332 times.
✓ Branch 1 taken 681 times.
✓ Branch 2 taken 331 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 331 times.
✗ Branch 5 not taken.
1013 if (compatrule_version < 76 && (tempheader.version_major >= 3 || tempheader.compareVer(2, 55, 10) < 0))
3451
2/2
✓ Branch 0 taken 332 times.
✓ Branch 1 taken 331 times.
1 set_qr(qr_INVERTED_DARK_COMBO_TRIGGERS, 1);
3452
2/2
✓ Branch 0 taken 350 times.
✓ Branch 1 taken 994 times.
1344 if (compatrule_version < 77)
3453
1/2
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
350 set_qr(qr_BROKEN_ICY_FLOOR_SIDEVIEW, 1);
3454
2/2
✓ Branch 0 taken 350 times.
✓ Branch 1 taken 994 times.
1344 if (compatrule_version < 78)
3455
1/2
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
350 set_qr(qr_SCRIPTS_SCREEN_DRAW_LIGHT_NO_OFFSET, 1);
3456
2/2
✓ Branch 0 taken 350 times.
✓ Branch 1 taken 994 times.
1344 if (compatrule_version < 79)
3457
1/2
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
350 set_qr(qr_BROKEN_SYSTEM_COLORS, 1);
3458
2/2
✓ Branch 0 taken 351 times.
✓ Branch 1 taken 993 times.
1344 if (compatrule_version < 80)
3459
1/2
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
351 set_qr(qr_ZS_OLD_SUSPEND_FFC, 1);
3460
5/6
✓ Branch 0 taken 358 times.
✓ Branch 1 taken 986 times.
✓ Branch 2 taken 331 times.
✓ Branch 3 taken 27 times.
✓ Branch 4 taken 331 times.
✗ Branch 5 not taken.
1344 if (compatrule_version < 81 && (tempheader.version_major >= 3 || tempheader.compareVer(2, 55, 10) < 0))
3461
2/2
✓ Branch 0 taken 358 times.
✓ Branch 1 taken 331 times.
27 set_qr(qr_BROKEN_SCROLL_INSTEAD_OF_DROWN_FALL, 1);
3462
3463
5/6
✓ Branch 0 taken 358 times.
✓ Branch 1 taken 1317 times.
✓ Branch 2 taken 331 times.
✓ Branch 3 taken 27 times.
✓ Branch 4 taken 331 times.
✗ Branch 5 not taken.
1675 if (compatrule_version < 81 && (tempheader.version_major >= 3 || tempheader.compareVer(2, 55, 6) < 0))
3464
2/2
✓ Branch 0 taken 358 times.
✓ Branch 1 taken 331 times.
27 set_qr(qr_ROPE_ENEMIES_SPEED_NOT_CONFIGURABLE, 1);
3465
3466
2/2
✓ Branch 0 taken 477 times.
✓ Branch 1 taken 1529 times.
2006 set_qr(qr_ANIMATECUSTOMWEAPONS,0);
3467
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 190 times.
477 if (s_version < 16)
3468
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_BROKEN_HORIZONTAL_WEAPON_ANIM,1);
3469
3470
1/2
✓ Branch 0 taken 477 times.
✗ Branch 1 not taken.
477 *Header = tempheader;
3471
3472 477 return 0;
3473 15313 }
3474
3475 4048985 void init_msgstr(MsgStr *str)
3476 {
3477
2/4
✓ Branch 0 taken 4048985 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4048985 times.
4048985 str->setFromLegacyEncoding("");
3478 4048985 str->nextstring=0;
3479 4048985 str->tile=0;
3480 4048985 str->cset=0;
3481 4048985 str->trans=false;
3482 4048985 str->font=font_zfont;
3483 4048985 str->y=32;
3484 4048985 str->sfx=18;
3485 4048985 str->listpos=0;
3486 4048985 str->x=24;
3487 4048985 str->w=get_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT)!=0 ? 24*8 : 26*8;
3488 4048985 str->h=get_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT)!=0 ? 3*8 : 5*8;
3489 4048985 str->hspace=0;
3490 4048985 str->vspace=0;
3491 4048985 str->stringflags=0;
3492 4048985 str->margins[up] = 8;
3493 4048985 str->margins[down] = 0;
3494 4048985 str->margins[left] = 8;
3495 4048985 str->margins[right] = 8;
3496 4048985 str->portrait_tile = 0;
3497 4048985 str->portrait_cset = 0;
3498 4048985 str->portrait_x = 0;
3499 4048985 str->portrait_y = 0;
3500 4048985 str->portrait_tw = 1;
3501 4048985 str->portrait_th = 1;
3502 4048985 str->shadow_type = 0;
3503 4048985 str->shadow_color = 0;
3504 4048985 str->drawlayer = 6;
3505 4048985 }
3506
3507 477 void init_msgstrings(int32_t start, int32_t end)
3508 {
3509
2/4
✓ Branch 0 taken 477 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 477 times.
477 if(end <= start || end-start > msg_strings_size)
3510 return;
3511
3512
2/2
✓ Branch 0 taken 477 times.
✓ Branch 1 taken 3907584 times.
3908061 for(int32_t i=start; i<end; i++)
3513 {
3514 3907584 init_msgstr(&MsgStrings[i]);
3515 3907584 MsgStrings[i].listpos=i;
3516 3907584 }
3517
3518
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 477 times.
477 if(start==0)
3519 {
3520
2/4
✓ Branch 0 taken 477 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 477 times.
477 MsgStrings[0].setFromLegacyEncoding("(None)");
3521 477 MsgStrings[0].listpos = 0;
3522 477 }
3523 477 }
3524
3525 478 int32_t readstrings(PACKFILE *f, zquestheader *Header)
3526 {
3527
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 454 times.
478 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_strings);
3528
3529 478 MsgStr tempMsgString;
3530
1/2
✓ Branch 0 taken 478 times.
✗ Branch 1 not taken.
478 init_msgstr(&tempMsgString);
3531
3532 478 word temp_msg_count=0;
3533 word temp_expansion[16];
3534 478 memset(temp_expansion, 0, 16*sizeof(word));
3535 478 char buf[8193] = {0};
3536
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 454 times.
478 if(Header->zelda_version < 0x193)
3537 {
3538 byte tempbyte;
3539 24 int32_t strings_to_read=0;
3540
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 1 times.
24 if (!should_skip)
3541
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_OLD_STRING_EDITOR_MARGINS,true);
3542
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
30 if((Header->zelda_version < 0x192)||
3543
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((Header->zelda_version == 0x192)&&(Header->build<31)))
3544 {
3545 18 strings_to_read=128;
3546 18 temp_msg_count=Header->old_str_count;
3547
3548 // Some sort of string count corruption seems to be common in old quests
3549
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(temp_msg_count>128)
3550 {
3551 temp_msg_count=128;
3552 }
3553 18 }
3554
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 else if((Header->zelda_version == 0x192)&&(Header->build<140))
3555 {
3556 strings_to_read=255;
3557 temp_msg_count=Header->old_str_count;
3558 }
3559 else
3560 {
3561
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!p_igetw(&temp_msg_count,f))
3562 {
3563 return qe_invalid;
3564 }
3565
3566 6 strings_to_read=temp_msg_count;
3567
3568
3/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
6 if (!should_skip && temp_msg_count >= msg_strings_size)
3569 {
3570 Z_message("Reallocating string buffer...\n");
3571
3572 // if((MsgStrings=(MsgStr*)_al_sane_realloc(MsgStrings,sizeof(MsgStr)*MAXMSGS))==NULL)
3573 // return qe_nomem;
3574
3575 //memset(MsgStrings, 0, sizeof(MsgStr)*MAXMSGS);
3576 delete[] MsgStrings;
3577 MsgStrings = new MsgStr[MAXMSGS];
3578 msg_strings_size = MAXMSGS;
3579 for(auto q = 0; q < msg_strings_size; ++q)
3580 {
3581 MsgStrings[q].clear();
3582 }
3583 }
3584 }
3585
3586 //reset the message strings
3587
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 1 times.
24 if (!should_skip)
3588
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 init_msgstrings(0,msg_strings_size);
3589
3590
2/2
✓ Branch 0 taken 2550 times.
✓ Branch 1 taken 24 times.
2574 for(int32_t x=0; x<strings_to_read; x++)
3591 {
3592
1/2
✓ Branch 0 taken 2550 times.
✗ Branch 1 not taken.
2550 init_msgstr(&tempMsgString);
3593 2550 tempMsgString.listpos = x;
3594
3595
2/4
✓ Branch 0 taken 2550 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2550 times.
✗ Branch 3 not taken.
2550 if(!pfread(buf,73,f))
3596 {
3597 return qe_invalid;
3598 }
3599
3600 2550 buf[74] = '\0';
3601
2/4
✓ Branch 0 taken 2550 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2550 times.
✗ Branch 3 not taken.
2550 tempMsgString.setFromLegacyEncoding(buf);
3602
3603
2/4
✓ Branch 0 taken 2550 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2550 times.
✗ Branch 3 not taken.
2550 if(!p_getc(&tempbyte,f))
3604 {
3605 return qe_invalid;
3606 }
3607
3608
3/4
✓ Branch 0 taken 246 times.
✓ Branch 1 taken 2304 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 246 times.
2796 if((Header->zelda_version < 0x192)||
3609
1/2
✓ Branch 0 taken 246 times.
✗ Branch 1 not taken.
246 ((Header->zelda_version == 0x192)&&(Header->build<148)))
3610 {
3611
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2304 times.
2304 tempMsgString.nextstring=tempbyte?x+1:0;
3612
3613
2/4
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2304 times.
✗ Branch 3 not taken.
2304 if(!p_getc(&tempbyte,f))
3614 {
3615 return qe_invalid;
3616 }
3617
3618
2/4
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2304 times.
✗ Branch 3 not taken.
2304 if(!p_getc(&tempbyte,f))
3619 {
3620 return qe_invalid;
3621 }
3622 2304 }
3623 else
3624 {
3625
2/4
✓ Branch 0 taken 246 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 246 times.
✗ Branch 3 not taken.
246 if(!p_igetw(&tempMsgString.nextstring,f))
3626 {
3627 return qe_invalid;
3628 }
3629
3630
2/4
✓ Branch 0 taken 246 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 246 times.
✗ Branch 3 not taken.
246 if(!pfread(temp_expansion,32,f))
3631 {
3632 return qe_invalid;
3633 }
3634 }
3635
3636
2/2
✓ Branch 0 taken 2549 times.
✓ Branch 1 taken 1 times.
2550 if (!should_skip)
3637 {
3638
1/2
✓ Branch 0 taken 2549 times.
✗ Branch 1 not taken.
2549 MsgStrings[x] = tempMsgString;
3639 2549 }
3640 2550 }
3641 24 }
3642 else
3643 {
3644 int32_t dummy_int;
3645 word s_version;
3646
3647 //section version info
3648
2/4
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 454 times.
✗ Branch 3 not taken.
454 if(!p_igetw(&s_version,f))
3649 {
3650 return qe_invalid;
3651 }
3652
3653 454 FFCore.quest_format[vStrings] = s_version;
3654
3655
2/4
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 454 times.
✗ Branch 3 not taken.
454 if(!read_deprecated_section_cversion(f))
3656 {
3657 return qe_invalid;
3658 }
3659
3660 //section size
3661
2/4
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 454 times.
✗ Branch 3 not taken.
454 if(!p_igetl(&dummy_int,f))
3662 {
3663 return qe_invalid;
3664 }
3665
3666 //finally... section data
3667
2/4
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 454 times.
✗ Branch 3 not taken.
454 if(!p_igetw(&temp_msg_count,f))
3668 {
3669 return qe_invalid;
3670 }
3671
3672
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 454 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
454 if(temp_msg_count >= msg_strings_size && !should_skip)
3673 {
3674 Z_message("Reallocating string buffer...\n");
3675
3676 delete[] MsgStrings;
3677 MsgStrings = new MsgStr[MAXMSGS];
3678 msg_strings_size = MAXMSGS;
3679 for(auto q = 0; q < msg_strings_size; ++q)
3680 {
3681 MsgStrings[q].clear();
3682 }
3683 }
3684
3685 //reset the message strings
3686
2/2
✓ Branch 0 taken 264 times.
✓ Branch 1 taken 190 times.
454 if(s_version < 7)
3687
1/2
✓ Branch 0 taken 264 times.
✗ Branch 1 not taken.
264 set_qr(qr_OLD_STRING_EDITOR_MARGINS,true);
3688
1/2
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
454 if (!should_skip)
3689
1/2
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
454 init_msgstrings(0,msg_strings_size);
3690
3691 454 int32_t string_length=(s_version<2)?73:145;
3692
3693
2/2
✓ Branch 0 taken 138373 times.
✓ Branch 1 taken 454 times.
138827 for(int32_t i=0; i<temp_msg_count; i++)
3694 {
3695
1/2
✓ Branch 0 taken 138373 times.
✗ Branch 1 not taken.
138373 init_msgstr(&tempMsgString);
3696 138373 tempMsgString.listpos = i;
3697
2/2
✓ Branch 0 taken 5834 times.
✓ Branch 1 taken 132539 times.
138373 if(s_version > 8)
3698 {
3699
2/4
✓ Branch 0 taken 5834 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5834 times.
✗ Branch 3 not taken.
5834 if(!p_igetl(&string_length,f))
3700 {
3701 return qe_invalid;
3702 }
3703 5834 }
3704
3705
2/4
✓ Branch 0 taken 138373 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 138373 times.
138373 if (string_length < 0 || string_length > 8193)
3706 {
3707 return qe_invalid;
3708 }
3709
3710
2/2
✓ Branch 0 taken 137821 times.
✓ Branch 1 taken 552 times.
138373 if (string_length > 0)
3711 {
3712
2/4
✓ Branch 0 taken 137821 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 137821 times.
✗ Branch 3 not taken.
137821 if (!pfread(buf, string_length, f))
3713 {
3714 return qe_invalid;
3715 }
3716 137821 }
3717 else
3718 {
3719 552 buf[0] = 0;
3720 }
3721
3722
2/4
✓ Branch 0 taken 138373 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 138373 times.
✗ Branch 3 not taken.
138373 if(!p_igetw(&tempMsgString.nextstring,f))
3723 {
3724 return qe_invalid;
3725 }
3726
3727
2/2
✓ Branch 0 taken 33613 times.
✓ Branch 1 taken 104760 times.
138373 if(s_version<2)
3728 {
3729 33613 buf[72] = '\0';
3730
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 33613 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 33613 times.
33613 tempMsgString.setFromLegacyEncoding(buf);
3731 33613 }
3732 else
3733 {
3734 // June 2008: A bug corrupted the last 4 chars of a string.
3735 // Discard these.
3736
1/2
✓ Branch 0 taken 104760 times.
✗ Branch 1 not taken.
104760 if(s_version<3)
3737 {
3738 for(int32_t j=140; j<144; j++)
3739 {
3740 buf[j] = '\0';
3741 }
3742 }
3743
1/2
✓ Branch 0 taken 104760 times.
✗ Branch 1 not taken.
104760 if(string_length > 8192) string_length = 8192;
3744 104760 buf[string_length]='\0'; //Force-terminate
3745
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 104760 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 104760 times.
104760 tempMsgString.setFromLegacyEncoding(buf);
3746
3747
2/2
✓ Branch 0 taken 5834 times.
✓ Branch 1 taken 98926 times.
104760 if ( s_version >= 6 )
3748 {
3749
2/4
✓ Branch 0 taken 5834 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5834 times.
✗ Branch 3 not taken.
5834 if(!p_igetl(&tempMsgString.tile,f))
3750 {
3751 return qe_invalid;
3752 }
3753 5834 }
3754 else
3755 {
3756
2/4
✓ Branch 0 taken 98926 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98926 times.
✗ Branch 3 not taken.
98926 if(!p_igetw(&tempMsgString.tile,f))
3757 {
3758 return qe_invalid;
3759 }
3760 }
3761
3762
2/4
✓ Branch 0 taken 104760 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104760 times.
✗ Branch 3 not taken.
104760 if(!p_getc(&tempMsgString.cset,f))
3763 {
3764 return qe_invalid;
3765 }
3766
3767 byte dummy_char;
3768
3769
2/4
✓ Branch 0 taken 104760 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104760 times.
✗ Branch 3 not taken.
104760 if(!p_getc(&dummy_char,f)) // trans is stored as a char...
3770 {
3771 return qe_invalid;
3772 }
3773
3774 104760 tempMsgString.trans=dummy_char!=0;
3775
3776
2/4
✓ Branch 0 taken 104760 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104760 times.
✗ Branch 3 not taken.
104760 if(!p_getc(&tempMsgString.font,f))
3777 {
3778 return qe_invalid;
3779 }
3780
3781
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104760 times.
104760 if(s_version < 5)
3782 {
3783 if(!p_getc(&tempMsgString.y,f))
3784 {
3785 return qe_invalid;
3786 }
3787 }
3788 else
3789 {
3790
2/4
✓ Branch 0 taken 104760 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104760 times.
✗ Branch 3 not taken.
104760 if(!p_igetw(&tempMsgString.x,f))
3791 {
3792 return qe_invalid;
3793 }
3794
3795
2/4
✓ Branch 0 taken 104760 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104760 times.
✗ Branch 3 not taken.
104760 if(!p_igetw(&tempMsgString.y,f))
3796 {
3797 return qe_invalid;
3798 }
3799
3800
2/4
✓ Branch 0 taken 104760 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104760 times.
✗ Branch 3 not taken.
104760 if(!p_igetw(&tempMsgString.w,f))
3801 {
3802 return qe_invalid;
3803 }
3804
3805
2/4
✓ Branch 0 taken 104760 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104760 times.
✗ Branch 3 not taken.
104760 if(!p_igetw(&tempMsgString.h,f))
3806 {
3807 return qe_invalid;
3808 }
3809
3810
2/4
✓ Branch 0 taken 104760 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104760 times.
✗ Branch 3 not taken.
104760 if(!p_getc(&tempMsgString.hspace,f))
3811 {
3812 return qe_invalid;
3813 }
3814
3815
2/4
✓ Branch 0 taken 104760 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104760 times.
✗ Branch 3 not taken.
104760 if(!p_getc(&tempMsgString.vspace,f))
3816 {
3817 return qe_invalid;
3818 }
3819
3820
2/4
✓ Branch 0 taken 104760 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104760 times.
✗ Branch 3 not taken.
104760 if(!p_getc(&tempMsgString.stringflags,f))
3821 {
3822 return qe_invalid;
3823 }
3824 }
3825
3826
2/2
✓ Branch 0 taken 98926 times.
✓ Branch 1 taken 5834 times.
104760 if(s_version >= 7)
3827 {
3828
2/2
✓ Branch 0 taken 5834 times.
✓ Branch 1 taken 23336 times.
29170 for(int32_t q = 0; q < 4; ++q)
3829 {
3830
2/4
✓ Branch 0 taken 23336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23336 times.
✗ Branch 3 not taken.
23336 if(!p_getc(&tempMsgString.margins[q],f))
3831 {
3832 return qe_invalid;
3833 }
3834 23336 }
3835
3836
2/4
✓ Branch 0 taken 5834 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5834 times.
✗ Branch 3 not taken.
5834 if(!p_igetl(&tempMsgString.portrait_tile,f))
3837 {
3838 return qe_invalid;
3839 }
3840
3841
2/4
✓ Branch 0 taken 5834 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5834 times.
✗ Branch 3 not taken.
5834 if(!p_getc(&tempMsgString.portrait_cset,f))
3842 {
3843 return qe_invalid;
3844 }
3845
3846
2/4
✓ Branch 0 taken 5834 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5834 times.
✗ Branch 3 not taken.
5834 if(!p_getc(&tempMsgString.portrait_x,f))
3847 {
3848 return qe_invalid;
3849 }
3850
3851
2/4
✓ Branch 0 taken 5834 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5834 times.
✗ Branch 3 not taken.
5834 if(!p_getc(&tempMsgString.portrait_y,f))
3852 {
3853 return qe_invalid;
3854 }
3855
3856
2/4
✓ Branch 0 taken 5834 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5834 times.
✗ Branch 3 not taken.
5834 if(!p_getc(&tempMsgString.portrait_tw,f))
3857 {
3858 return qe_invalid;
3859 }
3860
3861
2/4
✓ Branch 0 taken 5834 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5834 times.
✗ Branch 3 not taken.
5834 if(!p_getc(&tempMsgString.portrait_th,f))
3862 {
3863 return qe_invalid;
3864 }
3865 5834 }
3866
3867
2/2
✓ Branch 0 taken 5834 times.
✓ Branch 1 taken 98926 times.
104760 if(s_version >= 8)
3868 {
3869
2/4
✓ Branch 0 taken 5834 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5834 times.
✗ Branch 3 not taken.
5834 if(!p_getc(&tempMsgString.shadow_type,f))
3870 {
3871 return qe_invalid;
3872 }
3873
3874
2/4
✓ Branch 0 taken 5834 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5834 times.
✗ Branch 3 not taken.
5834 if(!p_getc(&tempMsgString.shadow_color,f))
3875 {
3876 return qe_invalid;
3877 }
3878 5834 }
3879
3880
2/2
✓ Branch 0 taken 5525 times.
✓ Branch 1 taken 99235 times.
104760 if(s_version >= 10)
3881 {
3882
2/4
✓ Branch 0 taken 5525 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5525 times.
✗ Branch 3 not taken.
5525 if(!p_getc(&tempMsgString.drawlayer,f))
3883 {
3884 return qe_invalid;
3885 }
3886 5525 }
3887
3888
2/4
✓ Branch 0 taken 104760 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104760 times.
✗ Branch 3 not taken.
104760 if(!p_getc(&tempMsgString.sfx,f))
3889 {
3890 return qe_invalid;
3891 }
3892
3893
1/2
✓ Branch 0 taken 104760 times.
✗ Branch 1 not taken.
104760 if(s_version>3)
3894 {
3895
2/4
✓ Branch 0 taken 104760 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104760 times.
✗ Branch 3 not taken.
104760 if(!p_igetw(&tempMsgString.listpos,f))
3896 {
3897 return qe_invalid;
3898 }
3899 104760 }
3900 }
3901
3902
1/2
✓ Branch 0 taken 138373 times.
✗ Branch 1 not taken.
138373 if (!should_skip)
3903 {
3904
1/2
✓ Branch 0 taken 138373 times.
✗ Branch 1 not taken.
138373 MsgStrings[i].copyAll(tempMsgString);
3905 138373 }
3906 138373 }
3907 }
3908
3909
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 477 times.
478 if (!should_skip)
3910 477 msg_count=temp_msg_count;
3911
3912 478 return 0;
3913 478 }
3914
3915 478 int32_t readdoorcombosets(PACKFILE *f, zquestheader *Header)
3916 {
3917
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 454 times.
478 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_doors);
3918
3919
3/4
✓ Branch 0 taken 460 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
484 if((Header->zelda_version < 0x192)||
3920
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 454 times.
460 ((Header->zelda_version == 0x192)&&(Header->build<158)))
3921 {
3922 18 return 0;
3923 }
3924
3925 460 word temp_door_combo_set_count=0;
3926 DoorComboSet tempDoorComboSet;
3927 word dummy_word;
3928 int32_t dummy_long;
3929 byte padding;
3930 460 int32_t s_version = 0;
3931
3932
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 459 times.
460 if (!should_skip)
3933 {
3934 459 DoorComboSets = {};
3935 459 DoorComboSetNames = {};
3936 459 }
3937
3938
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 454 times.
460 if(Header->zelda_version > 0x192)
3939 {
3940 //section version info
3941
1/2
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
454 if(!p_igetw(&s_version,f))
3942 {
3943 return qe_invalid;
3944 }
3945
3946 454 FFCore.quest_format[vDoors] = s_version;
3947
3948
1/2
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
454 if(!p_igetw(&dummy_word,f))
3949 {
3950 return qe_invalid;
3951 }
3952
3953 //section size
3954
1/2
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
454 if(!p_igetl(&dummy_long,f))
3955 {
3956 return qe_invalid;
3957 }
3958 454 }
3959
3960 //finally... section data
3961
1/2
✓ Branch 0 taken 460 times.
✗ Branch 1 not taken.
460 if(!p_igetw(&temp_door_combo_set_count,f))
3962 {
3963 return qe_invalid;
3964 }
3965
3966
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 460 times.
460 if (temp_door_combo_set_count > MAXDOORCOMBOSETS)
3967 {
3968 return qe_invalid;
3969 }
3970
3971
2/2
✓ Branch 0 taken 5400 times.
✓ Branch 1 taken 460 times.
5860 for(int32_t i=0; i<temp_door_combo_set_count; i++)
3972 {
3973 5400 memset(&tempDoorComboSet, 0, sizeof(DoorComboSet));
3974
3975 //name
3976 char name[21];
3977
1/2
✓ Branch 0 taken 5400 times.
✗ Branch 1 not taken.
5400 if(!pfread(&name,sizeof(name),f))
3978 {
3979 return qe_invalid;
3980 }
3981
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 5386 times.
5400 if (!should_skip)
3982 5386 DoorComboSetNames[i] = name;
3983
3984
2/2
✓ Branch 0 taken 5360 times.
✓ Branch 1 taken 40 times.
5400 if(Header->zelda_version < 0x193)
3985 {
3986
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if(!p_getc(&padding,f))
3987 {
3988 return qe_invalid;
3989 }
3990 40 }
3991
3992 //up door
3993
2/2
✓ Branch 0 taken 48600 times.
✓ Branch 1 taken 5400 times.
54000 for(int32_t j=0; j<9; j++)
3994 {
3995
2/2
✓ Branch 0 taken 194400 times.
✓ Branch 1 taken 48600 times.
243000 for(int32_t k=0; k<4; k++)
3996 {
3997
1/2
✓ Branch 0 taken 194400 times.
✗ Branch 1 not taken.
194400 if(!p_igetw(&tempDoorComboSet.doorcombo_u[j][k],f))
3998 {
3999 return qe_invalid;
4000 }
4001 194400 }
4002 48600 }
4003
4004
2/2
✓ Branch 0 taken 48600 times.
✓ Branch 1 taken 5400 times.
54000 for(int32_t j=0; j<9; j++)
4005 {
4006
2/2
✓ Branch 0 taken 194400 times.
✓ Branch 1 taken 48600 times.
243000 for(int32_t k=0; k<4; k++)
4007 {
4008
1/2
✓ Branch 0 taken 194400 times.
✗ Branch 1 not taken.
194400 if(!p_getc(&tempDoorComboSet.doorcset_u[j][k],f))
4009 {
4010 return qe_invalid;
4011 }
4012 194400 }
4013 48600 }
4014
4015 //down door
4016
2/2
✓ Branch 0 taken 48600 times.
✓ Branch 1 taken 5400 times.
54000 for(int32_t j=0; j<9; j++)
4017 {
4018
2/2
✓ Branch 0 taken 194400 times.
✓ Branch 1 taken 48600 times.
243000 for(int32_t k=0; k<4; k++)
4019 {
4020
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 194400 times.
194400 if(!p_igetw(&tempDoorComboSet.doorcombo_d[j][k],f))
4021 {
4022 return qe_invalid;
4023 }
4024 194400 }
4025 48600 }
4026
4027
2/2
✓ Branch 0 taken 48600 times.
✓ Branch 1 taken 5400 times.
54000 for(int32_t j=0; j<9; j++)
4028 {
4029
2/2
✓ Branch 0 taken 194400 times.
✓ Branch 1 taken 48600 times.
243000 for(int32_t k=0; k<4; k++)
4030 {
4031
1/2
✓ Branch 0 taken 194400 times.
✗ Branch 1 not taken.
194400 if(!p_getc(&tempDoorComboSet.doorcset_d[j][k],f))
4032 {
4033 return qe_invalid;
4034 }
4035 194400 }
4036 48600 }
4037
4038 //left door
4039
2/2
✓ Branch 0 taken 48600 times.
✓ Branch 1 taken 5400 times.
54000 for(int32_t j=0; j<9; j++)
4040 {
4041
2/2
✓ Branch 0 taken 291600 times.
✓ Branch 1 taken 48600 times.
340200 for(int32_t k=0; k<6; k++)
4042 {
4043
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 291600 times.
291600 if(!p_igetw(&tempDoorComboSet.doorcombo_l[j][k],f))
4044 {
4045 return qe_invalid;
4046 }
4047 291600 }
4048 48600 }
4049
4050
2/2
✓ Branch 0 taken 48600 times.
✓ Branch 1 taken 5400 times.
54000 for(int32_t j=0; j<9; j++)
4051 {
4052
2/2
✓ Branch 0 taken 291600 times.
✓ Branch 1 taken 48600 times.
340200 for(int32_t k=0; k<6; k++)
4053 {
4054
1/2
✓ Branch 0 taken 291600 times.
✗ Branch 1 not taken.
291600 if(!p_getc(&tempDoorComboSet.doorcset_l[j][k],f))
4055 {
4056 return qe_invalid;
4057 }
4058 291600 }
4059 48600 }
4060
4061 //right door
4062
2/2
✓ Branch 0 taken 48600 times.
✓ Branch 1 taken 5400 times.
54000 for(int32_t j=0; j<9; j++)
4063 {
4064
2/2
✓ Branch 0 taken 291600 times.
✓ Branch 1 taken 48600 times.
340200 for(int32_t k=0; k<6; k++)
4065 {
4066
1/2
✓ Branch 0 taken 291600 times.
✗ Branch 1 not taken.
291600 if(!p_igetw(&tempDoorComboSet.doorcombo_r[j][k],f))
4067 {
4068 return qe_invalid;
4069 }
4070 291600 }
4071 48600 }
4072
4073
2/2
✓ Branch 0 taken 48600 times.
✓ Branch 1 taken 5400 times.
54000 for(int32_t j=0; j<9; j++)
4074 {
4075
2/2
✓ Branch 0 taken 291600 times.
✓ Branch 1 taken 48600 times.
340200 for(int32_t k=0; k<6; k++)
4076 {
4077
1/2
✓ Branch 0 taken 291600 times.
✗ Branch 1 not taken.
291600 if(!p_getc(&tempDoorComboSet.doorcset_r[j][k],f))
4078 {
4079 return qe_invalid;
4080 }
4081 291600 }
4082 48600 }
4083
4084 //up bomb rubble
4085
2/2
✓ Branch 0 taken 10800 times.
✓ Branch 1 taken 5400 times.
16200 for(int32_t j=0; j<2; j++)
4086 {
4087
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10800 times.
10800 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_u[j],f))
4088 {
4089 return qe_invalid;
4090 }
4091 10800 }
4092
4093
2/2
✓ Branch 0 taken 10800 times.
✓ Branch 1 taken 5400 times.
16200 for(int32_t j=0; j<2; j++)
4094 {
4095
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10800 times.
10800 if(!p_getc(&tempDoorComboSet.bombdoorcset_u[j],f))
4096 {
4097 return qe_invalid;
4098 }
4099 10800 }
4100
4101 //down bomb rubble
4102
2/2
✓ Branch 0 taken 10800 times.
✓ Branch 1 taken 5400 times.
16200 for(int32_t j=0; j<2; j++)
4103 {
4104
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10800 times.
10800 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_d[j],f))
4105 {
4106 return qe_invalid;
4107 }
4108 10800 }
4109
4110
2/2
✓ Branch 0 taken 10800 times.
✓ Branch 1 taken 5400 times.
16200 for(int32_t j=0; j<2; j++)
4111 {
4112
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10800 times.
10800 if(!p_getc(&tempDoorComboSet.bombdoorcset_d[j],f))
4113 {
4114 return qe_invalid;
4115 }
4116 10800 }
4117
4118 //left bomb rubble
4119
2/2
✓ Branch 0 taken 16200 times.
✓ Branch 1 taken 5400 times.
21600 for(int32_t j=0; j<3; j++)
4120 {
4121
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16200 times.
16200 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_l[j],f))
4122 {
4123 return qe_invalid;
4124 }
4125 16200 }
4126
4127
2/2
✓ Branch 0 taken 16200 times.
✓ Branch 1 taken 5400 times.
21600 for(int32_t j=0; j<3; j++)
4128 {
4129
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16200 times.
16200 if(!p_getc(&tempDoorComboSet.bombdoorcset_l[j],f))
4130 {
4131 return qe_invalid;
4132 }
4133 16200 }
4134
4135
2/2
✓ Branch 0 taken 5360 times.
✓ Branch 1 taken 40 times.
5400 if(Header->zelda_version < 0x193)
4136 {
4137
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 if(!p_getc(&padding,f))
4138 {
4139 return qe_invalid;
4140 }
4141
4142 40 }
4143
4144 //right bomb rubble
4145
2/2
✓ Branch 0 taken 16200 times.
✓ Branch 1 taken 5400 times.
21600 for(int32_t j=0; j<3; j++)
4146 {
4147
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16200 times.
16200 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_r[j],f))
4148 {
4149 return qe_invalid;
4150 }
4151 16200 }
4152
4153
2/2
✓ Branch 0 taken 16200 times.
✓ Branch 1 taken 5400 times.
21600 for(int32_t j=0; j<3; j++)
4154 {
4155
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16200 times.
16200 if(!p_getc(&tempDoorComboSet.bombdoorcset_r[j],f))
4156 {
4157 return qe_invalid;
4158 }
4159 16200 }
4160
4161
2/2
✓ Branch 0 taken 5360 times.
✓ Branch 1 taken 40 times.
5400 if(Header->zelda_version < 0x193)
4162 {
4163
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 if(!p_getc(&padding,f))
4164 {
4165 return qe_invalid;
4166 }
4167 40 }
4168
4169 //walkthrough stuff
4170
2/2
✓ Branch 0 taken 21600 times.
✓ Branch 1 taken 5400 times.
27000 for(int32_t j=0; j<4; j++)
4171 {
4172
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21600 times.
21600 if(!p_igetw(&tempDoorComboSet.walkthroughcombo[j],f))
4173 {
4174 return qe_invalid;
4175 }
4176 21600 }
4177
4178
2/2
✓ Branch 0 taken 21600 times.
✓ Branch 1 taken 5400 times.
27000 for(int32_t j=0; j<4; j++)
4179 {
4180
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21600 times.
21600 if(!p_getc(&tempDoorComboSet.walkthroughcset[j],f))
4181 {
4182 return qe_invalid;
4183 }
4184 21600 }
4185
4186 //flags
4187
2/2
✓ Branch 0 taken 10800 times.
✓ Branch 1 taken 5400 times.
16200 for(int32_t j=0; j<2; j++)
4188 {
4189
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10800 times.
10800 if(!p_getc(&tempDoorComboSet.flags[j],f))
4190 {
4191 return qe_invalid;
4192 }
4193 10800 }
4194
4195
2/2
✓ Branch 0 taken 5360 times.
✓ Branch 1 taken 40 times.
5400 if(Header->zelda_version < 0x193)
4196 {
4197
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 if(!pfread(&tempDoorComboSet.expansion,sizeof(tempDoorComboSet.expansion),f))
4198 {
4199 return qe_invalid;
4200 }
4201 40 }
4202
4203
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 5386 times.
5400 if (!should_skip)
4204 5386 memcpy(&DoorComboSets[i], &tempDoorComboSet, sizeof(tempDoorComboSet));
4205 5400 }
4206
4207
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 459 times.
460 if (!should_skip)
4208 459 door_combo_set_count=temp_door_combo_set_count;
4209
4210 460 return 0;
4211 478 }
4212
4213 9 int32_t count_dmaps()
4214 {
4215 9 int32_t i=MAXDMAPS-1;
4216 9 bool found=false;
4217
4218
4/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 9 times.
9 while(i>=0 && !found)
4219 {
4220
4/6
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
27 if((DMaps[i].map!=0)||(DMaps[i].level!=0)||(DMaps[i].xoff!=0)||
4221
3/6
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
9 (DMaps[i].compass!=0)||(DMaps[i].color!=0)||(DMaps[i].midi!=0)||
4222
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 (DMaps[i].cont!=0)||(DMaps[i].type!=0))
4223 18 found=true;
4224
4225
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
90 for(int32_t j=0; j<8; j++)
4226 {
4227
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
72 if(DMaps[i].grid[j]!=0)
4228
4229 found=true;
4230 72 }
4231
4232
5/6
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
✓ Branch 4 taken 9 times.
✓ Branch 5 taken 9 times.
18 if((DMaps[i].name[0]!=0)||(DMaps[i].title[0]!=0)||
4233 (DMaps[i].intro[0]!=0)||(DMaps[i].tmusic[0]!=0))
4234 27 found=true;
4235
4236
3/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
27 if((DMaps[i].minimap_tile[0]!=0)||(DMaps[i].minimap_tile[1]!=0)||
4237
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 (DMaps[i].largemap_tile[0]!=0)||(DMaps[i].largemap_tile[1]!=0)||
4238
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 (DMaps[i].minimap_cset[0]!=0)||(DMaps[i].minimap_cset[1]!=0)||
4239
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 (DMaps[i].largemap_cset[0]!=0)||(DMaps[i].largemap_cset[1]!=0))
4240 18 found=true;
4241
4242 if(!found)
4243 {
4244 i--;
4245 }
4246 }
4247
4248 9 return i+1;
4249 }
4250
4251
4252 9 int32_t count_shops(miscQdata *Misc)
4253 {
4254 9 int32_t i=NUM_SHOPS-1,j;
4255 9 bool found=false;
4256
4257
4/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2234 times.
✓ Branch 2 taken 2229 times.
✓ Branch 3 taken 9 times.
2238 while(i>=0 && !found)
4258 {
4259 2229 j=2;
4260
4261
4/4
✓ Branch 0 taken 2224 times.
✓ Branch 1 taken 6682 times.
✓ Branch 2 taken 6677 times.
✓ Branch 3 taken 2229 times.
8906 while(j>=0 && !found)
4262 {
4263
3/4
✓ Branch 0 taken 6672 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6672 times.
6677 if((Misc->shop[i].hasitem[j]!=0)||(Misc->shop[i].price[j]!=0))
4264 {
4265 5 found=true;
4266 5 }
4267 else
4268 {
4269 6672 j--;
4270 }
4271 }
4272
4273
1/2
✓ Branch 0 taken 2229 times.
✗ Branch 1 not taken.
2229 if(Misc->shop[i].name[0]!=0)
4274 {
4275 found=true;
4276 }
4277
4278
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2224 times.
2229 if(!found)
4279 {
4280 2224 i--;
4281 2224 }
4282 }
4283
4284 9 return i+1;
4285 }
4286
4287 9 int32_t count_infos(miscQdata *Misc)
4288 {
4289 9 int32_t i=255,j;
4290 9 bool found=false;
4291
4292
4/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2234 times.
✓ Branch 2 taken 2229 times.
✓ Branch 3 taken 9 times.
2238 while(i>=0 && !found)
4293 {
4294 2229 j=2;
4295
4296
4/4
✓ Branch 0 taken 2224 times.
✓ Branch 1 taken 6682 times.
✓ Branch 2 taken 6677 times.
✓ Branch 3 taken 2229 times.
8906 while(j>=0 && !found)
4297 {
4298
4/4
✓ Branch 0 taken 6676 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 6672 times.
6677 if((Misc->info[i].str[j]!=0)||(Misc->info[i].price[j]!=0))
4299 {
4300 5 found=true;
4301 5 }
4302 else
4303 {
4304 6672 j--;
4305 }
4306 }
4307
4308
1/2
✓ Branch 0 taken 2229 times.
✗ Branch 1 not taken.
2229 if(Misc->info[i].name[0]!=0)
4309 {
4310 found=true;
4311 }
4312
4313
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2224 times.
2229 if(!found)
4314 {
4315 2224 i--;
4316 2224 }
4317 }
4318
4319 9 return i+1;
4320 }
4321
4322 9 int32_t count_warprings(miscQdata *Misc)
4323 {
4324 9 int32_t i=15,j;
4325 9 bool found=false;
4326
4327
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
✓ Branch 2 taken 49 times.
✓ Branch 3 taken 9 times.
58 while(i>=0 && !found)
4328 {
4329 49 j=7;
4330
4331
4/4
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 367 times.
✓ Branch 2 taken 358 times.
✓ Branch 3 taken 49 times.
407 while(j>=0 && !found)
4332 {
4333
4/4
✓ Branch 0 taken 354 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 349 times.
358 if((Misc->warp[i].dmap[j]!=0)||(Misc->warp[i].scr[j]!=0))
4334 {
4335 9 found=true;
4336 9 }
4337 else
4338 {
4339 349 j--;
4340 }
4341 }
4342
4343
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 40 times.
49 if(!found)
4344 {
4345 40 i--;
4346 40 }
4347 }
4348
4349 9 return i+1;
4350 }
4351
4352 9 int32_t count_palcycles(miscQdata *Misc)
4353 {
4354 9 int32_t i=255,j;
4355 9 bool found=false;
4356
4357
4/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2043 times.
✓ Branch 2 taken 2036 times.
✓ Branch 3 taken 9 times.
2045 while(i>=0 && !found)
4358 {
4359 2036 j=2;
4360
4361
4/4
✓ Branch 0 taken 2029 times.
✓ Branch 1 taken 6101 times.
✓ Branch 2 taken 6094 times.
✓ Branch 3 taken 2036 times.
8130 while(j>=0 && !found)
4362 {
4363
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 6087 times.
6094 if(Misc->cycles[i][j].count!=0)
4364 {
4365 7 found=true;
4366 7 }
4367 else
4368 {
4369 6087 j--;
4370 }
4371 }
4372
4373
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 2029 times.
2036 if(!found)
4374 {
4375 2029 i--;
4376 2029 }
4377 }
4378
4379 9 return i+1;
4380 }
4381
4382 18088 void clear_screen(mapscr *temp_scr)
4383 {
4384 18088 temp_scr->zero_memory();
4385 18088 }
4386
4387 // NOTE: when modifying this, you need to also update:
4388 // readonedmap, readdmaps, and FFScript::read_dmaps
4389 // (and their associated write functions)
4390 3550 int32_t readdmaps(PACKFILE *f, zquestheader *Header, word, word, word start_dmap, word max_dmaps)
4391 {
4392
2/2
✓ Branch 0 taken 3526 times.
✓ Branch 1 taken 24 times.
3550 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_dmaps);
4393
4394 3550 word dmapstoread=0;
4395 3550 dmap tempDMap;
4396
4397 int32_t dummy;
4398 3550 word s_version=0;
4399 byte padding;
4400
4401 char legacy_title[22];
4402
4403
2/2
✓ Branch 0 taken 3073 times.
✓ Branch 1 taken 477 times.
3550 if (!should_skip)
4404
2/2
✓ Branch 0 taken 244224 times.
✓ Branch 1 taken 477 times.
244701 for(int32_t i=0; i<max_dmaps; i++)
4405 {
4406
1/2
✓ Branch 0 taken 244224 times.
✗ Branch 1 not taken.
244224 DMaps[start_dmap + i].clear();
4407 244224 sprintf(legacy_title," ");
4408 244224 sprintf(DMaps[start_dmap+i].intro," ");
4409 244224 DMaps[start_dmap+i].type |= dmCAVE;
4410 244701 }
4411
4412
3/4
✓ Branch 0 taken 477 times.
✓ Branch 1 taken 3073 times.
✓ Branch 2 taken 477 times.
✗ Branch 3 not taken.
3550 if (!should_skip && s_version == 21)
4413 Regions = {};
4414
4415 3550 Header->is_z3 = false;
4416
4/4
✓ Branch 0 taken 478 times.
✓ Branch 1 taken 3072 times.
✓ Branch 2 taken 454 times.
✓ Branch 3 taken 24 times.
3550 if(!Header || Header->zelda_version > 0x192)
4417 {
4418 //section version info
4419
3/4
✓ Branch 0 taken 454 times.
✓ Branch 1 taken 3072 times.
✓ Branch 2 taken 454 times.
✗ Branch 3 not taken.
3526 if(!p_igetw(&s_version,f))
4420 {
4421 return qe_invalid;
4422 }
4423 454 Header->is_z3 = s_version >= 22;
4424
4425 454 FFCore.quest_format[vDMaps] = s_version;
4426
4427
4428
2/4
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 454 times.
✗ Branch 3 not taken.
454 if(!read_deprecated_section_cversion(f))
4429 {
4430 return qe_invalid;
4431 }
4432
4433 //section size
4434
2/4
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 454 times.
✗ Branch 3 not taken.
454 if(!p_igetl(&dummy,f))
4435 {
4436 return qe_invalid;
4437 }
4438
4439 //finally... section data
4440
2/4
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 454 times.
✗ Branch 3 not taken.
454 if(!p_igetw(&dmapstoread,f))
4441 {
4442 return qe_invalid;
4443 }
4444 454 }
4445 else
4446 {
4447
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
30 if((Header->zelda_version < 0x192)||
4448
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((Header->zelda_version == 0x192)&&(Header->build<5)))
4449 {
4450 18 dmapstoread=32;
4451 18 }
4452
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 else if(s_version <= 4)
4453 {
4454 6 dmapstoread=OLDMAXDMAPS;
4455 6 }
4456 else
4457 {
4458 dmapstoread=MAXDMAPS;
4459 }
4460 }
4461
4462
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 395 times.
478 dmapstoread=zc_min(dmapstoread, max_dmaps);
4463
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 395 times.
478 dmapstoread=zc_min(dmapstoread, MAXDMAPS-start_dmap);
4464
4465
2/2
✓ Branch 0 taken 219456 times.
✓ Branch 1 taken 478 times.
219934 for(int32_t i=start_dmap; i<dmapstoread+start_dmap; i++)
4466 {
4467
1/2
✓ Branch 0 taken 219456 times.
✗ Branch 1 not taken.
219456 tempDMap.clear();
4468 219456 sprintf(legacy_title," ");
4469 219456 sprintf(tempDMap.intro," ");
4470
4471
2/4
✓ Branch 0 taken 219456 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 219456 times.
✗ Branch 3 not taken.
219456 if(!p_getc(&tempDMap.map,f))
4472 {
4473 return qe_invalid;
4474 }
4475
4476
2/2
✓ Branch 0 taken 17216 times.
✓ Branch 1 taken 202240 times.
219456 if(s_version <= 4)
4477 {
4478 byte tempbyte;
4479
4480
2/4
✓ Branch 0 taken 17216 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17216 times.
✗ Branch 3 not taken.
17216 if(!p_getc(&tempbyte,f))
4481 {
4482 return qe_invalid;
4483 }
4484
4485 17216 tempDMap.level=(word)tempbyte;
4486 17216 }
4487 else
4488 {
4489
2/4
✓ Branch 0 taken 202240 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202240 times.
✗ Branch 3 not taken.
202240 if(!p_igetw(&tempDMap.level,f))
4490 {
4491 return qe_invalid;
4492 }
4493 }
4494
4495
2/4
✓ Branch 0 taken 219456 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 219456 times.
✗ Branch 3 not taken.
219456 if(!p_getc(&tempDMap.xoff,f))
4496 {
4497 return qe_invalid;
4498 }
4499
4500
2/4
✓ Branch 0 taken 219456 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 219456 times.
✗ Branch 3 not taken.
219456 if(!p_getc(&tempDMap.compass,f))
4501 {
4502 return qe_invalid;
4503 }
4504
4505
2/2
✓ Branch 0 taken 202240 times.
✓ Branch 1 taken 17216 times.
219456 if(s_version > 8) // February 2009
4506 {
4507
2/4
✓ Branch 0 taken 202240 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202240 times.
✗ Branch 3 not taken.
202240 if(!p_igetw(&tempDMap.color,f))
4508 {
4509 return qe_invalid;
4510 }
4511 202240 }
4512 else
4513 {
4514 byte tempbyte;
4515
4516
2/4
✓ Branch 0 taken 17216 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17216 times.
✗ Branch 3 not taken.
17216 if(!p_getc(&tempbyte,f))
4517 {
4518 return qe_invalid;
4519 }
4520
4521 17216 tempDMap.color = (word)tempbyte;
4522 }
4523
4524
2/4
✓ Branch 0 taken 219456 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 219456 times.
✗ Branch 3 not taken.
219456 if(!p_getc(&tempDMap.midi,f))
4525 {
4526 return qe_invalid;
4527 }
4528
4529
2/4
✓ Branch 0 taken 219456 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 219456 times.
✗ Branch 3 not taken.
219456 if(!p_getc(&tempDMap.cont,f))
4530 {
4531 return qe_invalid;
4532 }
4533
4534
2/4
✓ Branch 0 taken 219456 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 219456 times.
✗ Branch 3 not taken.
219456 if(!p_getc(&tempDMap.type,f))
4535 {
4536 return qe_invalid;
4537 }
4538
4539
4/4
✓ Branch 0 taken 5954 times.
✓ Branch 1 taken 213502 times.
✓ Branch 2 taken 5910 times.
✓ Branch 3 taken 44 times.
225410 if((tempDMap.type & dmfTYPE) == dmOVERW &&
4540
1/2
✓ Branch 0 taken 5954 times.
✗ Branch 1 not taken.
5954 (!Header || Header->zelda_version >= 0x210)) // Not sure exactly when this changed
4541 5910 tempDMap.xoff = 0;
4542
4543
2/2
✓ Branch 0 taken 219456 times.
✓ Branch 1 taken 1755648 times.
1975104 for(int32_t j=0; j<8; j++)
4544 {
4545
2/4
✓ Branch 0 taken 1755648 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1755648 times.
✗ Branch 3 not taken.
1755648 if(!p_getc(&tempDMap.grid[j],f))
4546 {
4547 return qe_invalid;
4548 }
4549 1755648 }
4550
4551
5/6
✓ Branch 0 taken 219456 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 218880 times.
✓ Branch 3 taken 576 times.
✓ Branch 4 taken 1536 times.
✓ Branch 5 taken 217344 times.
219456 if(Header && ((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<41))))
4552 {
4553
4/4
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 1975 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 127 times.
2112 if(tempDMap.level>0&&tempDMap.level<10)
4554 {
4555 127 sprintf(legacy_title,"LEVEL-%d ", tempDMap.level);
4556 127 }
4557
2/2
✓ Branch 0 taken 576 times.
✓ Branch 1 taken 1536 times.
2112 tempDMap.title.assign(legacy_title);
4558
4559
3/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 558 times.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
576 if(i==0 && Header->zelda_version <= 0x190)
4560 {
4561
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 tempDMap.cont = std::max((int)tempDMap.cont - tempDMap.xoff, 0);
4562
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 tempDMap.compass = std::max((int)tempDMap.compass - tempDMap.xoff, 0);
4563 18 }
4564
4565 //forgotten -DD
4566
2/2
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 439 times.
576 if(tempDMap.level==0)
4567 {
4568 439 tempDMap.flags=dmfCAVES|dmf3STAIR|dmfWHIRLWIND|dmfGUYCAVES;
4569 439 }
4570 576 }
4571 else
4572 {
4573
3/4
✓ Branch 0 taken 218880 times.
✓ Branch 1 taken 1536 times.
✓ Branch 2 taken 218880 times.
✗ Branch 3 not taken.
217344 if(!p_getstr(tempDMap.name,sizeof(DMaps[0].name) - 1,f))
4574 {
4575 return qe_invalid;
4576 }
4577
4578
2/2
✓ Branch 0 taken 130304 times.
✓ Branch 1 taken 88576 times.
218880 if(s_version<20)
4579 {
4580
2/4
✓ Branch 0 taken 130304 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 130304 times.
✗ Branch 3 not taken.
130304 if (!p_getstr(legacy_title, sizeof(legacy_title) - 1, f))
4581 {
4582 return qe_invalid;
4583 }
4584
1/2
✓ Branch 0 taken 130304 times.
✗ Branch 1 not taken.
130304 tempDMap.title.assign(legacy_title);
4585 130304 }
4586 else
4587 {
4588
2/4
✓ Branch 0 taken 88576 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 88576 times.
✗ Branch 3 not taken.
88576 if (!p_getwstr(&tempDMap.title, f))
4589 {
4590 return qe_invalid;
4591 }
4592 }
4593
4594
2/4
✓ Branch 0 taken 218880 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 218880 times.
✗ Branch 3 not taken.
218880 if(!p_getstr(tempDMap.intro,sizeof(DMaps[0].intro)-1,f))
4595 {
4596 return qe_invalid;
4597 }
4598
4599
5/8
✓ Branch 0 taken 218880 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 218880 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1536 times.
✓ Branch 5 taken 217344 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1536 times.
218880 if(Header && ((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<152))))
4600 {
4601 if ((tempDMap.type & dmfTYPE) == dmOVERW) tempDMap.flags = dmfCAVES | dmf3STAIR | dmfWHIRLWIND | dmfGUYCAVES;
4602 DMaps[i] = tempDMap;
4603
4604 continue;
4605 }
4606
4607
3/4
✓ Branch 0 taken 218880 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✓ Branch 3 taken 217344 times.
218880 if(Header && (Header->zelda_version < 0x193))
4608 {
4609
2/4
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
1536 if(!p_getc(&padding,f))
4610 {
4611 return qe_invalid;
4612 }
4613 1536 }
4614
2/2
✓ Branch 0 taken 97280 times.
✓ Branch 1 taken 121600 times.
218880 if ( s_version >= 11 )
4615 {
4616
2/4
✓ Branch 0 taken 97280 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 97280 times.
✗ Branch 3 not taken.
97280 if(!p_igetl(&tempDMap.minimap_tile[0],f))
4617 {
4618 return qe_invalid;
4619 }
4620 97280 }
4621 else
4622 {
4623
2/4
✓ Branch 0 taken 121600 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 121600 times.
✗ Branch 3 not taken.
121600 if(!p_igetw(&tempDMap.minimap_tile[0],f))
4624 {
4625 return qe_invalid;
4626 }
4627 }
4628
4629
2/4
✓ Branch 0 taken 218880 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 218880 times.
✗ Branch 3 not taken.
218880 if(!p_getc(&tempDMap.minimap_cset[0],f))
4630 {
4631 return qe_invalid;
4632 }
4633
4634
3/4
✓ Branch 0 taken 218880 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✓ Branch 3 taken 217344 times.
218880 if(Header && (Header->zelda_version < 0x193))
4635 {
4636
2/4
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
1536 if(!p_getc(&padding,f))
4637 {
4638 return qe_invalid;
4639 }
4640 1536 }
4641
4642
2/2
✓ Branch 0 taken 97280 times.
✓ Branch 1 taken 121600 times.
218880 if ( s_version >= 11 )
4643 {
4644
2/4
✓ Branch 0 taken 97280 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 97280 times.
✗ Branch 3 not taken.
97280 if(!p_igetl(&tempDMap.minimap_tile[1],f))
4645 {
4646 return qe_invalid;
4647 }
4648 97280 }
4649 else
4650 {
4651
2/4
✓ Branch 0 taken 121600 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 121600 times.
✗ Branch 3 not taken.
121600 if(!p_igetw(&tempDMap.minimap_tile[1],f))
4652 {
4653 return qe_invalid;
4654 }
4655 }
4656
2/4
✓ Branch 0 taken 218880 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 218880 times.
✗ Branch 3 not taken.
218880 if(!p_getc(&tempDMap.minimap_cset[1],f))
4657 {
4658 return qe_invalid;
4659 }
4660
4661
3/4
✓ Branch 0 taken 218880 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✓ Branch 3 taken 217344 times.
218880 if(Header && (Header->zelda_version < 0x193))
4662 {
4663
2/4
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
1536 if(!p_getc(&padding,f))
4664 {
4665 return qe_invalid;
4666 }
4667 1536 }
4668
4669
2/2
✓ Branch 0 taken 97280 times.
✓ Branch 1 taken 121600 times.
218880 if ( s_version >= 11 )
4670 {
4671
2/4
✓ Branch 0 taken 97280 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 97280 times.
✗ Branch 3 not taken.
97280 if(!p_igetl(&tempDMap.largemap_tile[0],f))
4672 {
4673 return qe_invalid;
4674 }
4675 97280 }
4676 else
4677 {
4678
2/4
✓ Branch 0 taken 121600 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 121600 times.
✗ Branch 3 not taken.
121600 if(!p_igetw(&tempDMap.largemap_tile[0],f))
4679 {
4680 return qe_invalid;
4681 }
4682 }
4683
4684
2/4
✓ Branch 0 taken 218880 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 218880 times.
✗ Branch 3 not taken.
218880 if(!p_getc(&tempDMap.largemap_cset[0],f))
4685 {
4686 return qe_invalid;
4687 }
4688
4689
3/4
✓ Branch 0 taken 218880 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✓ Branch 3 taken 217344 times.
218880 if(Header && (Header->zelda_version < 0x193))
4690 {
4691
4692
2/4
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
1536 if(!p_getc(&padding,f))
4693 {
4694 return qe_invalid;
4695 }
4696 1536 }
4697
4698
2/2
✓ Branch 0 taken 97280 times.
✓ Branch 1 taken 121600 times.
218880 if ( s_version >= 11 )
4699 {
4700
2/4
✓ Branch 0 taken 97280 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 97280 times.
✗ Branch 3 not taken.
97280 if(!p_igetl(&tempDMap.largemap_tile[1],f))
4701 {
4702 return qe_invalid;
4703 }
4704 97280 }
4705 else
4706 {
4707
2/4
✓ Branch 0 taken 121600 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 121600 times.
✗ Branch 3 not taken.
121600 if(!p_igetw(&tempDMap.largemap_tile[1],f))
4708 {
4709 return qe_invalid;
4710 }
4711 }
4712
2/4
✓ Branch 0 taken 218880 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 218880 times.
✗ Branch 3 not taken.
218880 if(!p_getc(&tempDMap.largemap_cset[1],f))
4713 {
4714 return qe_invalid;
4715 }
4716
4717
2/4
✓ Branch 0 taken 218880 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 218880 times.
✗ Branch 3 not taken.
218880 if(!p_getstr(tempDMap.tmusic,sizeof(DMaps[0].tmusic)-1,f))
4718 {
4719 return qe_invalid;
4720 }
4721 }
4722
4723
2/2
✓ Branch 0 taken 202240 times.
✓ Branch 1 taken 17216 times.
219456 if(s_version>1)
4724 {
4725
2/4
✓ Branch 0 taken 202240 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202240 times.
✗ Branch 3 not taken.
202240 if(!p_getc(&tempDMap.tmusictrack,f))
4726 {
4727 return qe_invalid;
4728 }
4729
4730
2/4
✓ Branch 0 taken 202240 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202240 times.
✗ Branch 3 not taken.
202240 if(!p_getc(&tempDMap.active_subscreen,f))
4731 {
4732 return qe_invalid;
4733 }
4734
4735
2/4
✓ Branch 0 taken 202240 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202240 times.
✗ Branch 3 not taken.
202240 if(!p_getc(&tempDMap.passive_subscreen,f))
4736 {
4737 return qe_invalid;
4738 }
4739 202240 }
4740
4741
2/2
✓ Branch 0 taken 202240 times.
✓ Branch 1 taken 17216 times.
219456 if(s_version>2)
4742 {
4743 byte di[32];
4744
4745
2/4
✓ Branch 0 taken 202240 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202240 times.
✗ Branch 3 not taken.
202240 if(!pfread(&di, 32, f)) return qe_invalid;
4746
4747
2/2
✓ Branch 0 taken 51773440 times.
✓ Branch 1 taken 202240 times.
51975680 for(int32_t j=0; j<MAXITEMS; j++)
4748 {
4749
2/2
✓ Branch 0 taken 9207 times.
✓ Branch 1 taken 51764233 times.
51773440 if(di[j/8] & (1 << (j%8))) tempDMap.disableditems[j]=1;
4750 51764233 else tempDMap.disableditems[j]=0;
4751 51773440 }
4752 202240 }
4753
4754
2/2
✓ Branch 0 taken 202240 times.
✓ Branch 1 taken 17216 times.
219456 if(s_version >= 6)
4755 {
4756
2/4
✓ Branch 0 taken 202240 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202240 times.
✗ Branch 3 not taken.
202240 if(!p_igetl(&tempDMap.flags,f))
4757 {
4758 return qe_invalid;
4759 }
4760 202240 }
4761
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17216 times.
17216 else if(s_version>3)
4762 {
4763 char temp;
4764
4765 if(!p_getc(&temp,f))
4766 {
4767 return qe_invalid;
4768 }
4769
4770 tempDMap.flags = temp;
4771 }
4772
3/8
✓ Branch 0 taken 8992 times.
✓ Branch 1 taken 8224 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8992 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
17216 else if(tempDMap.level==0 && ((Header->zelda_version < 0x211) || ((Header->zelda_version == 0x211) && (Header->build<18))))
4773 {
4774 8992 tempDMap.flags=dmfCAVES|dmf3STAIR|dmfWHIRLWIND|dmfGUYCAVES;
4775 8992 }
4776 else
4777 8224 tempDMap.flags=0;
4778
4779
2/2
✓ Branch 0 taken 202240 times.
✓ Branch 1 taken 17216 times.
219456 if(s_version<7)
4780 {
4781
5/6
✓ Branch 0 taken 8992 times.
✓ Branch 1 taken 8224 times.
✓ Branch 2 taken 8992 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2846 times.
✓ Branch 5 taken 6146 times.
17216 if(tempDMap.level==0 && get_bit(deprecated_rules,14))
4782 6146 tempDMap.flags|= dmfVIEWMAP;
4783 17216 }
4784
4785
2/2
✓ Branch 0 taken 202240 times.
✓ Branch 1 taken 17216 times.
219456 if(s_version<8)
4786 {
4787
4/4
✓ Branch 0 taken 8992 times.
✓ Branch 1 taken 8224 times.
✓ Branch 2 taken 8050 times.
✓ Branch 3 taken 942 times.
17216 if(tempDMap.level==0 && (tempDMap.type&dmfTYPE)==dmDNGN)
4788 {
4789
1/2
✓ Branch 0 taken 8050 times.
✗ Branch 1 not taken.
8050 tempDMap.type &= ~dmDNGN;
4790 8050 tempDMap.type |= dmCAVE;
4791 8050 }
4792
2/2
✓ Branch 0 taken 6834 times.
✓ Branch 1 taken 2332 times.
9166 else if((tempDMap.type&dmfTYPE)==dmCAVE)
4793 {
4794 2332 tempDMap.flags |= dmfMINIMAPCOLORFIX;
4795 2332 }
4796 17216 }
4797
4798
7/8
✓ Branch 0 taken 219456 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2112 times.
✓ Branch 3 taken 217344 times.
✓ Branch 4 taken 1536 times.
✓ Branch 5 taken 576 times.
✓ Branch 6 taken 1536 times.
✓ Branch 7 taken 217344 times.
219456 if(Header && ((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>=41)))
4799 218880 && (Header->zelda_version < 0x193))
4800 {
4801
2/4
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
1536 if(!p_getc(&padding,f))
4802 {
4803 return qe_invalid;
4804 }
4805 1536 }
4806
4807
2/2
✓ Branch 0 taken 122176 times.
✓ Branch 1 taken 97280 times.
219456 if(s_version >= 10)
4808 {
4809
2/4
✓ Branch 0 taken 97280 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 97280 times.
✗ Branch 3 not taken.
97280 if(!p_getc(&tempDMap.sideview,f))
4810 {
4811 return qe_invalid;
4812 }
4813 97280 }
4814
2/2
✓ Branch 0 taken 97280 times.
✓ Branch 1 taken 122176 times.
219456 if(s_version < 10) tempDMap.sideview = 0;
4815
4816 //Dmap Scripts
4817
2/2
✓ Branch 0 taken 97280 times.
✓ Branch 1 taken 122176 times.
219456 if(s_version >= 12)
4818 {
4819
2/4
✓ Branch 0 taken 97280 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 97280 times.
✗ Branch 3 not taken.
97280 if(!p_igetw(&tempDMap.script,f))
4820 {
4821 return qe_invalid;
4822 }
4823
2/2
✓ Branch 0 taken 778240 times.
✓ Branch 1 taken 97280 times.
875520 for ( int32_t q = 0; q < 8; q++ )
4824 {
4825
2/4
✓ Branch 0 taken 778240 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 778240 times.
✗ Branch 3 not taken.
778240 if(!p_igetl(&tempDMap.initD[q],f))
4826 {
4827 return qe_invalid;
4828 }
4829 778240 }
4830 97280 }
4831
2/2
✓ Branch 0 taken 97280 times.
✓ Branch 1 taken 122176 times.
219456 if ( s_version < 12 )
4832 {
4833 122176 tempDMap.script = 0;
4834
2/2
✓ Branch 0 taken 977408 times.
✓ Branch 1 taken 122176 times.
1099584 for ( int32_t q = 0; q < 8; q++ )
4835 {
4836 977408 tempDMap.initD[q] = 0;
4837 977408 }
4838 122176 }
4839
4840
2/2
✓ Branch 0 taken 122176 times.
✓ Branch 1 taken 97280 times.
219456 if(s_version >= 13)
4841 {
4842
2/2
✓ Branch 0 taken 778240 times.
✓ Branch 1 taken 97280 times.
875520 for ( int32_t q = 0; q < 8; q++ )
4843 {
4844
2/2
✓ Branch 0 taken 50585600 times.
✓ Branch 1 taken 778240 times.
51363840 for ( int32_t w = 0; w < 65; w++ )
4845 {
4846
2/4
✓ Branch 0 taken 50585600 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50585600 times.
✗ Branch 3 not taken.
50585600 if(!p_getc(&tempDMap.initD_label[q][w],f))
4847 {
4848 return qe_invalid;
4849 }
4850 50585600 }
4851 778240 }
4852 97280 }
4853
2/2
✓ Branch 0 taken 97280 times.
✓ Branch 1 taken 122176 times.
219456 if ( s_version < 13 )
4854 {
4855 122176 tempDMap.script = 0;
4856
2/2
✓ Branch 0 taken 977408 times.
✓ Branch 1 taken 122176 times.
1099584 for ( int32_t q = 0; q < 8; q++ )
4857 {
4858
2/2
✓ Branch 0 taken 63531520 times.
✓ Branch 1 taken 977408 times.
64508928 for ( int32_t w = 0; w < 65; w++ )
4859 63531520 tempDMap.initD_label[q][w] = 0;
4860 977408 }
4861 122176 }
4862
2/2
✓ Branch 0 taken 97280 times.
✓ Branch 1 taken 122176 times.
219456 if(s_version >= 14)
4863 {
4864
2/4
✓ Branch 0 taken 97280 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 97280 times.
✗ Branch 3 not taken.
97280 if(!p_igetw(&tempDMap.active_sub_script,f))
4865 {
4866 return qe_invalid;
4867 }
4868
2/4
✓ Branch 0 taken 97280 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 97280 times.
✗ Branch 3 not taken.
97280 if(!p_igetw(&tempDMap.passive_sub_script,f))
4869 {
4870 return qe_invalid;
4871 }
4872
2/2
✓ Branch 0 taken 778240 times.
✓ Branch 1 taken 97280 times.
875520 for ( int32_t q = 0; q < 8; ++q )
4873 {
4874
2/4
✓ Branch 0 taken 778240 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 778240 times.
✗ Branch 3 not taken.
778240 if(!p_igetl(&tempDMap.sub_initD[q],f))
4875 {
4876 return qe_invalid;
4877 }
4878 778240 }
4879
2/2
✓ Branch 0 taken 778240 times.
✓ Branch 1 taken 97280 times.
875520 for(int32_t q = 0; q < 8; ++q)
4880 {
4881
2/2
✓ Branch 0 taken 50585600 times.
✓ Branch 1 taken 778240 times.
51363840 for ( int32_t w = 0; w < 65; ++w )
4882 {
4883
2/4
✓ Branch 0 taken 50585600 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50585600 times.
✗ Branch 3 not taken.
50585600 if(!p_getc(&tempDMap.sub_initD_label[q][w],f))
4884 {
4885 return qe_invalid;
4886 }
4887 50585600 }
4888 778240 }
4889 97280 }
4890 else
4891 {
4892 122176 tempDMap.active_sub_script = 0;
4893 122176 tempDMap.passive_sub_script = 0;
4894
2/2
✓ Branch 0 taken 977408 times.
✓ Branch 1 taken 122176 times.
1099584 for(int32_t q = 0; q < 8; ++q)
4895 {
4896 977408 tempDMap.sub_initD[q] = 0;
4897
2/2
✓ Branch 0 taken 63531520 times.
✓ Branch 1 taken 977408 times.
64508928 for(int32_t w = 0; w < 65; ++w)
4898 63531520 tempDMap.sub_initD_label[q][w] = 0;
4899 977408 }
4900 }
4901
2/2
✓ Branch 0 taken 97280 times.
✓ Branch 1 taken 122176 times.
219456 if(s_version >= 15)
4902 {
4903
2/4
✓ Branch 0 taken 97280 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 97280 times.
✗ Branch 3 not taken.
97280 if(!p_igetw(&tempDMap.onmap_script,f))
4904 {
4905 return qe_invalid;
4906 }
4907
2/2
✓ Branch 0 taken 778240 times.
✓ Branch 1 taken 97280 times.
875520 for ( int32_t q = 0; q < 8; ++q )
4908 {
4909
2/4
✓ Branch 0 taken 778240 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 778240 times.
✗ Branch 3 not taken.
778240 if(!p_igetl(&tempDMap.onmap_initD[q],f))
4910 {
4911 return qe_invalid;
4912 }
4913 778240 }
4914
2/2
✓ Branch 0 taken 778240 times.
✓ Branch 1 taken 97280 times.
875520 for(int32_t q = 0; q < 8; ++q)
4915 {
4916
2/2
✓ Branch 0 taken 50585600 times.
✓ Branch 1 taken 778240 times.
51363840 for ( int32_t w = 0; w < 65; ++w )
4917 {
4918
2/4
✓ Branch 0 taken 50585600 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50585600 times.
✗ Branch 3 not taken.
50585600 if(!p_getc(&tempDMap.onmap_initD_label[q][w],f))
4919 {
4920 return qe_invalid;
4921 }
4922 50585600 }
4923 778240 }
4924 97280 }
4925 else
4926 {
4927 122176 tempDMap.onmap_script = 0;
4928
2/2
✓ Branch 0 taken 977408 times.
✓ Branch 1 taken 122176 times.
1099584 for(int32_t q = 0; q < 8; ++q)
4929 {
4930 977408 tempDMap.onmap_initD[q] = 0;
4931
2/2
✓ Branch 0 taken 63531520 times.
✓ Branch 1 taken 977408 times.
64508928 for(int32_t w = 0; w < 65; ++w)
4932 {
4933 63531520 tempDMap.onmap_initD_label[q][w] = 0;
4934 63531520 }
4935 977408 }
4936 }
4937
2/2
✓ Branch 0 taken 97280 times.
✓ Branch 1 taken 122176 times.
219456 if(s_version >= 16)
4938 {
4939
2/4
✓ Branch 0 taken 97280 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 97280 times.
✗ Branch 3 not taken.
97280 if(!p_igetw(&tempDMap.mirrorDMap,f))
4940 {
4941 return qe_invalid;
4942 }
4943 97280 }
4944 else
4945 {
4946 122176 tempDMap.mirrorDMap = -1;
4947 }
4948
4949 // Enhanced music loop points
4950
2/2
✓ Branch 0 taken 88576 times.
✓ Branch 1 taken 130880 times.
219456 if (s_version >= 18)
4951 {
4952
2/4
✓ Branch 0 taken 88576 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 88576 times.
✗ Branch 3 not taken.
88576 if (!p_igetl(&tempDMap.tmusic_loop_start, f))
4953 {
4954 return qe_invalid;
4955 }
4956
2/4
✓ Branch 0 taken 88576 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 88576 times.
✗ Branch 3 not taken.
88576 if (!p_igetl(&tempDMap.tmusic_loop_end, f))
4957 {
4958 return qe_invalid;
4959 }
4960
2/4
✓ Branch 0 taken 88576 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 88576 times.
✗ Branch 3 not taken.
88576 if (!p_igetl(&tempDMap.tmusic_xfade_in, f))
4961 {
4962 return qe_invalid;
4963 }
4964
2/4
✓ Branch 0 taken 88576 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 88576 times.
✗ Branch 3 not taken.
88576 if (!p_igetl(&tempDMap.tmusic_xfade_out, f))
4965 {
4966 return qe_invalid;
4967 }
4968 88576 }
4969 else
4970 {
4971 130880 tempDMap.tmusic_loop_start = 0;
4972 130880 tempDMap.tmusic_loop_end = 0;
4973 130880 tempDMap.tmusic_xfade_in = 0;
4974 130880 tempDMap.tmusic_xfade_out = 0;
4975 }
4976
4977
2/2
✓ Branch 0 taken 88576 times.
✓ Branch 1 taken 130880 times.
219456 if(s_version >= 19)
4978
2/4
✓ Branch 0 taken 88576 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 88576 times.
✗ Branch 3 not taken.
88576 if(!p_getc(&tempDMap.overlay_subscreen, f))
4979 return qe_invalid;
4980
4981
2/2
✓ Branch 0 taken 88576 times.
✓ Branch 1 taken 130880 times.
219456 if (s_version >= 20)
4982 {
4983
2/4
✓ Branch 0 taken 88576 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 88576 times.
✗ Branch 3 not taken.
88576 if (!p_igetl(&tempDMap.intro_string_id, f))
4984 return qe_invalid;
4985 88576 }
4986 else
4987 130880 tempDMap.intro_string_id = 0;
4988
4989
2/2
✓ Branch 0 taken 205120 times.
✓ Branch 1 taken 14336 times.
219456 if(s_version == 21)
4990 {
4991 static regions_data tmp_rd;
4992
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14336 times.
14336 regions_data& rd = should_skip ? tmp_rd : Regions[tempDMap.map];
4993
2/2
✓ Branch 0 taken 114688 times.
✓ Branch 1 taken 14336 times.
129024 for(int32_t j=0; j<8; j++)
4994 {
4995
2/2
✓ Branch 0 taken 917504 times.
✓ Branch 1 taken 114688 times.
1032192 for(int32_t k=0; k<8; k++)
4996 {
4997
2/4
✓ Branch 0 taken 917504 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 917504 times.
✗ Branch 3 not taken.
917504 if(!p_getc(&rd.region_ids[j][k],f))
4998 {
4999 return qe_invalid;
5000 }
5001 917504 }
5002 114688 }
5003 14336 }
5004
5005
2/2
✓ Branch 0 taken 219200 times.
✓ Branch 1 taken 256 times.
219456 if (!should_skip)
5006 {
5007
1/2
✓ Branch 0 taken 219200 times.
✗ Branch 1 not taken.
219200 if(loading_tileset_flags & TILESET_CLEARMAPS)
5008 tempDMap.map = 0;
5009
1/2
✓ Branch 0 taken 219200 times.
✗ Branch 1 not taken.
219200 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
5010 {
5011 tempDMap.script = 0;
5012 for(int q = 0; q < 8; ++q)
5013 tempDMap.initD[q] = 0;
5014 }
5015
1/2
✓ Branch 0 taken 219200 times.
✗ Branch 1 not taken.
219200 DMaps[i] = tempDMap;
5016 219200 }
5017 219456 }
5018
5019 478 return 0;
5020 6622 }
5021
5022 395 int32_t readmisccolors(PACKFILE *f, zquestheader *Header, miscQdata *Misc)
5023 {
5024 //these are here to bypass compiler warnings about unused arguments
5025 395 Header=Header;
5026
5027 miscQdata temp_misc;
5028 395 word s_version=0;
5029 395 int32_t tempsize=0;
5030 word dummyw;
5031
5032 395 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5033
5034 //section version info
5035
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 395 times.
395 if(!p_igetw(&s_version,f))
5036 {
5037 return qe_invalid;
5038 }
5039
5040 395 FFCore.quest_format[vColours] = s_version;
5041
5042 395 al_trace("Misc Colours section version: %d\n", s_version);
5043
5044
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 if(!read_deprecated_section_cversion(f))
5045 {
5046 return qe_invalid;
5047 }
5048
5049
5050 //section size
5051
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 if(!p_igetl(&tempsize,f))
5052 {
5053 return qe_invalid;
5054 }
5055
5056 //finally... section data
5057 395 readsize=0;
5058
5059
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 if(!p_getc(&temp_misc.colors.text,f))
5060 {
5061 return qe_invalid;
5062 }
5063
5064
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 if(!p_getc(&temp_misc.colors.caption,f))
5065 {
5066 return qe_invalid;
5067 }
5068
5069
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 if(!p_getc(&temp_misc.colors.overw_bg,f))
5070 {
5071 return qe_invalid;
5072 }
5073
5074
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 if(!p_getc(&temp_misc.colors.dngn_bg,f))
5075 {
5076 return qe_invalid;
5077 }
5078
5079
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 if(!p_getc(&temp_misc.colors.dngn_fg,f))
5080 {
5081 return qe_invalid;
5082 }
5083
5084
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 if(!p_getc(&temp_misc.colors.cave_fg,f))
5085 {
5086 return qe_invalid;
5087 }
5088
5089
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 if(!p_getc(&temp_misc.colors.bs_dk,f))
5090 {
5091 return qe_invalid;
5092 }
5093
5094
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 if(!p_getc(&temp_misc.colors.bs_goal,f))
5095 {
5096 return qe_invalid;
5097 }
5098
5099
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 if(!p_getc(&temp_misc.colors.compass_lt,f))
5100 {
5101 return qe_invalid;
5102 }
5103
5104
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 if(!p_getc(&temp_misc.colors.compass_dk,f))
5105 {
5106 return qe_invalid;
5107 }
5108
5109
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 if(!p_getc(&temp_misc.colors.subscr_bg,f))
5110 {
5111 return qe_invalid;
5112 }
5113
5114
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 if(!p_getc(&temp_misc.colors.triframe_color,f))
5115 {
5116 return qe_invalid;
5117 }
5118
5119
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 if(!p_getc(&temp_misc.colors.hero_dot,f))
5120 {
5121 return qe_invalid;
5122 }
5123
5124
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 if(!p_getc(&temp_misc.colors.bmap_bg,f))
5125 {
5126 return qe_invalid;
5127 }
5128
5129
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 if(!p_getc(&temp_misc.colors.bmap_fg,f))
5130 {
5131 return qe_invalid;
5132 }
5133
5134
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 if(!p_getc(&temp_misc.colors.triforce_cset,f))
5135 {
5136 return qe_invalid;
5137 }
5138
5139
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 if(!p_getc(&temp_misc.colors.triframe_cset,f))
5140 {
5141 return qe_invalid;
5142 }
5143
5144
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 if(!p_getc(&temp_misc.colors.overworld_map_cset,f))
5145 {
5146 return qe_invalid;
5147 }
5148
5149
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 if(!p_getc(&temp_misc.colors.dungeon_map_cset,f))
5150 {
5151 return qe_invalid;
5152 }
5153
5154
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 if(!p_getc(&temp_misc.colors.blueframe_cset,f))
5155 {
5156 return qe_invalid;
5157 }
5158
2/2
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 205 times.
395 if(s_version < 4)
5159 {
5160
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 if(!p_igetw(&dummyw,f))
5161 return qe_invalid;
5162 205 temp_misc.colors.triforce_tile = dummyw;
5163
5164
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 if(!p_igetw(&dummyw,f))
5165 return qe_invalid;
5166 205 temp_misc.colors.triframe_tile = dummyw;
5167
5168
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 if(!p_igetw(&dummyw,f))
5169 return qe_invalid;
5170 205 temp_misc.colors.overworld_map_tile = dummyw;
5171
5172
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 if(!p_igetw(&dummyw,f))
5173 return qe_invalid;
5174 205 temp_misc.colors.dungeon_map_tile = dummyw;
5175
5176
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 if(!p_igetw(&dummyw,f))
5177 return qe_invalid;
5178 205 temp_misc.colors.blueframe_tile = dummyw;
5179
5180
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 if(!p_igetw(&dummyw,f))
5181 return qe_invalid;
5182 205 temp_misc.colors.HCpieces_tile = dummyw;
5183 205 }
5184
5185
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 if(!p_getc(&temp_misc.colors.HCpieces_cset,f))
5186 {
5187 return qe_invalid;
5188 }
5189
5190
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 if(!p_getc(&temp_misc.colors.subscr_shadow,f))
5191 {
5192 return qe_invalid;
5193 }
5194
5195
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 395 times.
395 if(s_version < 2)
5196 {
5197 temp_misc.colors.msgtext = 0x01;
5198 }
5199 else
5200 {
5201
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 if(!p_getc(&temp_misc.colors.msgtext, f))
5202 {
5203 return qe_invalid;
5204 }
5205 }
5206
5207
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 190 times.
395 if ( s_version >= 3 ) //expanded tile pages to 825
5208 {
5209
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if(!p_igetl(&temp_misc.colors.triforce_tile,f))
5210 {
5211 return qe_invalid;
5212 }
5213
5214
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if(!p_igetl(&temp_misc.colors.triframe_tile,f))
5215 {
5216 return qe_invalid;
5217 }
5218
5219
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if(!p_igetl(&temp_misc.colors.overworld_map_tile,f))
5220 {
5221 return qe_invalid;
5222 }
5223
5224
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if(!p_igetl(&temp_misc.colors.dungeon_map_tile,f))
5225 {
5226 return qe_invalid;
5227 }
5228
5229
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if(!p_igetl(&temp_misc.colors.blueframe_tile,f))
5230 {
5231 return qe_invalid;
5232 }
5233
5234
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if(!p_igetl(&temp_misc.colors.HCpieces_tile,f))
5235 {
5236 return qe_invalid;
5237 }
5238 190 }
5239
5240 395 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5241
5242 395 return 0;
5243 395 }
5244
5245 395 int32_t readgameicons(PACKFILE *f, zquestheader *, miscQdata *Misc)
5246 {
5247 miscQdata temp_misc;
5248 395 word s_version=0;
5249 byte icons;
5250 395 int32_t tempsize=0;
5251
5252 395 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5253
5254 //section version info
5255
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 395 times.
395 if(!p_igetw(&s_version,f))
5256 {
5257 return qe_invalid;
5258 }
5259
5260 395 FFCore.quest_format[vIcons] = s_version;
5261
5262
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 if(!read_deprecated_section_cversion(f))
5263 {
5264 return qe_invalid;
5265 }
5266
5267
5268 //section size
5269
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 if(!p_igetl(&tempsize,f))
5270 {
5271 return qe_invalid;
5272 }
5273
5274 //finally... section data
5275 395 readsize=0;
5276
5277 395 icons=4;
5278
5279
2/2
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 205 times.
395 if ( s_version >= 10 )
5280 {
5281
2/2
✓ Branch 0 taken 760 times.
✓ Branch 1 taken 190 times.
950 for(int32_t i=0; i<icons; i++)
5282 {
5283
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 760 times.
760 if(!p_igetl(&temp_misc.icons[i],f))
5284 {
5285 return qe_invalid;
5286 }
5287 760 }
5288 190 }
5289 else
5290 {
5291
2/2
✓ Branch 0 taken 820 times.
✓ Branch 1 taken 205 times.
1025 for(int32_t i=0; i<icons; i++)
5292 {
5293
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 820 times.
820 if(!p_igetw(&temp_misc.icons[i],f))
5294 {
5295 return qe_invalid;
5296 }
5297 820 }
5298 }
5299
5300 395 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5301
5302 395 return 0;
5303 395 }
5304
5305 798 int32_t readmisc(PACKFILE *f, zquestheader *Header, miscQdata *Misc)
5306 {
5307
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 774 times.
798 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_misc);
5308
5309 798 word maxinfos=256;
5310 798 word maxshops=256;
5311 798 word shops=16, infos=16, warprings=8, palcycles=256, windwarps=9, triforces=8, icons=4;
5312 798 word ponds=16, pondsize=72, expansionsize=98*2;
5313 byte tempbyte, padding;
5314 miscQdata temp_misc;
5315 798 word s_version=0;
5316 word swaptmp;
5317 798 int32_t tempsize=0;
5318
5319 798 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5320
5321
2/2
✓ Branch 0 taken 204288 times.
✓ Branch 1 taken 798 times.
205086 for(int32_t i=0; i<maxshops; ++i)
5322 {
5323 204288 memset(&temp_misc.shop, 0, sizeof(shoptype)*256);
5324 204288 }
5325
5326
2/2
✓ Branch 0 taken 204288 times.
✓ Branch 1 taken 798 times.
205086 for(int32_t i=0; i<maxinfos; ++i)
5327 {
5328 204288 memset(&temp_misc.info, 0, sizeof(infotype)*256);
5329 204288 }
5330
5331 798 memset(&temp_misc.warp, 0, sizeof(temp_misc.warp));
5332
5333
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 774 times.
798 if(Header->zelda_version > 0x192)
5334 {
5335 //section version info
5336
1/2
✓ Branch 0 taken 774 times.
✗ Branch 1 not taken.
774 if(!p_igetw(&s_version,f))
5337 {
5338 return qe_invalid;
5339 }
5340
5341 774 FFCore.quest_format[vMisc] = s_version;
5342
5343
1/2
✓ Branch 0 taken 774 times.
✗ Branch 1 not taken.
774 if(!read_deprecated_section_cversion(f))
5344 {
5345 return qe_invalid;
5346 }
5347
5348
5349 //section size
5350
1/2
✓ Branch 0 taken 774 times.
✗ Branch 1 not taken.
774 if(!p_igetl(&tempsize,f))
5351 {
5352 return qe_invalid;
5353 }
5354 774 }
5355
5356 //finally... section data
5357 798 readsize=0;
5358
5359 //shops
5360
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 774 times.
798 if(Header->zelda_version > 0x192)
5361 {
5362
1/2
✓ Branch 0 taken 774 times.
✗ Branch 1 not taken.
774 if(!p_igetw(&shops,f))
5363 {
5364 return qe_invalid;
5365 }
5366 774 }
5367
5368
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 798 times.
798 if (shops > NUM_SHOPS)
5369 {
5370 return qe_invalid;
5371 }
5372
5373
2/2
✓ Branch 0 taken 10974 times.
✓ Branch 1 taken 798 times.
11772 for(int32_t i=0; i<shops; i++)
5374 {
5375
2/2
✓ Branch 0 taken 1200 times.
✓ Branch 1 taken 9774 times.
10974 if(s_version > 6)
5376 {
5377
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9774 times.
9774 if(!p_getstr(temp_misc.shop[i].name,sizeof(temp_misc.shop[i].name)-1,f))
5378 {
5379 return qe_invalid;
5380 }
5381 9774 }
5382
5383
2/2
✓ Branch 0 taken 32922 times.
✓ Branch 1 taken 10974 times.
43896 for(int32_t j=0; j<3; j++)
5384 {
5385
1/2
✓ Branch 0 taken 32922 times.
✗ Branch 1 not taken.
32922 if(!p_getc(&temp_misc.shop[i].item[j],f))
5386 {
5387 return qe_invalid;
5388 }
5389
5390
2/2
✓ Branch 0 taken 29322 times.
✓ Branch 1 taken 3600 times.
32922 if(s_version < 4)
5391 {
5392 3600 temp_misc.shop[i].hasitem[j] = (temp_misc.shop[i].item[j] == 0) ? 0 : 1;
5393 3600 }
5394 32922 }
5395
5396
2/2
✓ Branch 0 taken 10590 times.
✓ Branch 1 taken 384 times.
10974 if(Header->zelda_version < 0x193)
5397 {
5398
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
384 if(!p_getc(&tempbyte,f))
5399 {
5400 return qe_invalid;
5401 }
5402 384 }
5403
5404
2/2
✓ Branch 0 taken 32922 times.
✓ Branch 1 taken 10974 times.
43896 for(int32_t j=0; j<3; j++)
5405 {
5406
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32922 times.
32922 if(!p_igetw(&temp_misc.shop[i].price[j],f))
5407 {
5408 return qe_invalid;
5409 }
5410 32922 }
5411
5412
2/2
✓ Branch 0 taken 1200 times.
✓ Branch 1 taken 9774 times.
10974 if(s_version > 3)
5413 {
5414
2/2
✓ Branch 0 taken 29322 times.
✓ Branch 1 taken 9774 times.
39096 for(int32_t j=0; j<3; j++)
5415 {
5416
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29322 times.
29322 if(!p_getc(&temp_misc.shop[i].hasitem[j],f))
5417 return qe_invalid;
5418 29322 }
5419 9774 }
5420
5421 /*
5422 if(s_version < 8)
5423 {
5424 for(int32_t j=0; j<3; j++)
5425 {
5426 (&temp_misc.shop[i].str[j])=0; //initialise.
5427 }
5428 }
5429 */
5430 10974 }
5431
5432 //filter all the 0 items to the end (yeah, bubble sort; sue me)
5433
2/2
✓ Branch 0 taken 204288 times.
✓ Branch 1 taken 798 times.
205086 for(int32_t i=0; i<maxshops; ++i)
5434 {
5435
2/2
✓ Branch 0 taken 408576 times.
✓ Branch 1 taken 204288 times.
612864 for(int32_t j=0; j<3-1; j++)
5436 {
5437
2/2
✓ Branch 0 taken 612864 times.
✓ Branch 1 taken 408576 times.
1021440 for(int32_t k=0; k<2-j; k++)
5438 {
5439
2/2
✓ Branch 0 taken 23704 times.
✓ Branch 1 taken 589160 times.
612864 if(temp_misc.shop[i].hasitem[k]==0)
5440 {
5441 589160 swaptmp = temp_misc.shop[i].item[k];
5442 589160 temp_misc.shop[i].item[k] = temp_misc.shop[i].item[k+1];
5443 589160 temp_misc.shop[i].item[k+1] = swaptmp;
5444 589160 swaptmp = temp_misc.shop[i].price[k];
5445 589160 temp_misc.shop[i].price[k] = temp_misc.shop[i].price[k+1];
5446 589160 temp_misc.shop[i].price[k+1] = swaptmp;
5447 589160 swaptmp = temp_misc.shop[i].hasitem[k];
5448 589160 temp_misc.shop[i].hasitem[k] = temp_misc.shop[i].hasitem[k+1];
5449 589160 temp_misc.shop[i].hasitem[k+1] = swaptmp;
5450 589160 }
5451 612864 }
5452 408576 }
5453 204288 }
5454
5455 //infos
5456
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 774 times.
798 if(Header->zelda_version > 0x192)
5457 {
5458
1/2
✓ Branch 0 taken 774 times.
✗ Branch 1 not taken.
774 if(!p_igetw(&infos,f))
5459 {
5460 return qe_invalid;
5461 }
5462 774 }
5463
5464
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 798 times.
798 if (infos > NUM_INFOS)
5465 {
5466 return qe_invalid;
5467 }
5468
5469
5470
2/2
✓ Branch 0 taken 10280 times.
✓ Branch 1 taken 798 times.
11078 for(int32_t i=0; i<infos; i++)
5471 {
5472
2/2
✓ Branch 0 taken 761 times.
✓ Branch 1 taken 9519 times.
10280 if(s_version > 6)
5473 {
5474
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9519 times.
9519 if(!p_getstr(temp_misc.info[i].name,sizeof(temp_misc.info[i].name)-1,f))
5475 {
5476 return qe_invalid;
5477 }
5478 9519 }
5479
5480
2/2
✓ Branch 0 taken 30840 times.
✓ Branch 1 taken 10280 times.
41120 for(int32_t j=0; j<3; j++)
5481 {
5482
3/4
✓ Branch 0 taken 29976 times.
✓ Branch 1 taken 864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 288 times.
31128 if((Header->zelda_version < 0x192)||
5483
2/2
✓ Branch 0 taken 288 times.
✓ Branch 1 taken 29688 times.
29976 ((Header->zelda_version == 0x192)&&(Header->build<146)))
5484 {
5485
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 864 times.
864 if(!p_getc(&tempbyte,f))
5486 {
5487 return qe_invalid;
5488 }
5489
5490 864 temp_misc.info[i].str[j]=tempbyte;
5491 864 }
5492 else
5493 {
5494
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29976 times.
29976 if(!p_igetw(&temp_misc.info[i].str[j],f))
5495 {
5496 return qe_invalid;
5497 }
5498 }
5499 30840 }
5500
5501
2/2
✓ Branch 0 taken 9896 times.
✓ Branch 1 taken 384 times.
10280 if(Header->zelda_version < 0x193)
5502 {
5503
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_getc(&tempbyte,f))
5504 {
5505 return qe_invalid;
5506 }
5507 384 }
5508
5509
3/4
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 10184 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 96 times.
10280 if((Header->zelda_version == 0x192)&&(Header->build>145))
5510 {
5511
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&padding,f))
5512 {
5513 return qe_invalid;
5514 }
5515 96 }
5516
5517
2/2
✓ Branch 0 taken 30840 times.
✓ Branch 1 taken 10280 times.
41120 for(int32_t j=0; j<3; j++)
5518 {
5519
1/2
✓ Branch 0 taken 30840 times.
✗ Branch 1 not taken.
30840 if(!p_igetw(&temp_misc.info[i].price[j],f))
5520 {
5521 return qe_invalid;
5522 }
5523 30840 }
5524 10280 }
5525
5526 //filter all the 0 strings to the end (yeah, bubble sort; sue me)
5527
2/2
✓ Branch 0 taken 204288 times.
✓ Branch 1 taken 798 times.
205086 for(int32_t i=0; i<maxinfos; ++i)
5528 {
5529
2/2
✓ Branch 0 taken 408576 times.
✓ Branch 1 taken 204288 times.
612864 for(int32_t j=0; j<3-1; j++)
5530 {
5531
2/2
✓ Branch 0 taken 612864 times.
✓ Branch 1 taken 408576 times.
1021440 for(int32_t k=0; k<2-j; k++)
5532 {
5533
2/2
✓ Branch 0 taken 11644 times.
✓ Branch 1 taken 601220 times.
612864 if(temp_misc.info[i].str[k]==0)
5534 {
5535 601220 swaptmp = temp_misc.info[i].str[k];
5536 601220 temp_misc.info[i].str[k] = temp_misc.info[i].str[k+1];
5537 601220 temp_misc.info[i].str[k+1] = swaptmp;
5538 601220 swaptmp = temp_misc.info[i].price[k];
5539 601220 temp_misc.info[i].price[k] = temp_misc.info[i].price[k+1];
5540 601220 temp_misc.info[i].price[k+1] = swaptmp;
5541 601220 }
5542 612864 }
5543 408576 }
5544 204288 }
5545
5546
5547 //warp rings
5548
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 715 times.
798 if(s_version > 5)
5549 715 warprings++;
5550
5551
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 774 times.
798 if(Header->zelda_version > 0x192)
5552 {
5553
1/2
✓ Branch 0 taken 774 times.
✗ Branch 1 not taken.
774 if(!p_igetw(&warprings,f))
5554 {
5555 return qe_invalid;
5556 }
5557
5558
2/2
✓ Branch 0 taken 338 times.
✓ Branch 1 taken 436 times.
774 if (warprings > NUM_WARP_RINGS)
5559 {
5560 // return qe_invalid;
5561 // Note: we can't actually fail here because for some reason, some quest files have more than the max
5562 // number of possible warp rings. Some examples of this are: demosp253.qst, yuurand.qst
5563 // So instead below we disable `keepdata` when reading the bad warp ring data, so no memory is corrupted.
5564 436 }
5565 774 }
5566
5567
2/2
✓ Branch 0 taken 8342 times.
✓ Branch 1 taken 798 times.
9140 for(int32_t i=0; i<warprings; i++)
5568 {
5569 // See above comment on the `warprings` range check.
5570 8342 bool keepdata = i < NUM_WARP_RINGS;
5571
5572
2/2
✓ Branch 0 taken 73958 times.
✓ Branch 1 taken 8342 times.
82300 for(int32_t j=0; j<8+((s_version > 5)?1:0); j++)
5573 {
5574
2/2
✓ Branch 0 taken 8960 times.
✓ Branch 1 taken 64998 times.
73958 if(s_version <= 3)
5575 {
5576
1/2
✓ Branch 0 taken 8960 times.
✗ Branch 1 not taken.
8960 if(!p_getc(&tempbyte,f))
5577 {
5578 return qe_invalid;
5579 }
5580
5581
2/2
✓ Branch 0 taken 3192 times.
✓ Branch 1 taken 5768 times.
8960 if (keepdata)
5582 5768 temp_misc.warp[i].dmap[j]=(word)tempbyte;
5583 8960 }
5584 else
5585 {
5586 word tempword;
5587
1/2
✓ Branch 0 taken 64998 times.
✗ Branch 1 not taken.
64998 if(!p_igetw(&tempword,f))
5588 {
5589 return qe_invalid;
5590 }
5591
5592
2/2
✓ Branch 0 taken 7389 times.
✓ Branch 1 taken 57609 times.
64998 if (keepdata)
5593 57609 temp_misc.warp[i].dmap[j] = tempword;
5594 }
5595 73958 }
5596
5597
2/2
✓ Branch 0 taken 73958 times.
✓ Branch 1 taken 8342 times.
82300 for(int32_t j=0; j<8+((s_version > 5)?1:0); j++)
5598 {
5599
1/2
✓ Branch 0 taken 73958 times.
✗ Branch 1 not taken.
73958 if(!p_getc(&tempbyte,f))
5600 {
5601 return qe_invalid;
5602 }
5603
2/2
✓ Branch 0 taken 10581 times.
✓ Branch 1 taken 63377 times.
73958 if (keepdata)
5604 63377 temp_misc.warp[i].scr[j] = tempbyte;
5605 73958 }
5606
5607
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8342 times.
8342 if(!p_getc(&tempbyte,f))
5608 {
5609 return qe_invalid;
5610 }
5611
2/2
✓ Branch 0 taken 1220 times.
✓ Branch 1 taken 7122 times.
8342 if (keepdata)
5612 7122 temp_misc.warp[i].size = tempbyte;
5613
5614
2/2
✓ Branch 0 taken 8150 times.
✓ Branch 1 taken 192 times.
8342 if(Header->zelda_version < 0x193)
5615 {
5616
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(!p_getc(&tempbyte,f))
5617 {
5618 return qe_invalid;
5619 }
5620 192 }
5621 8342 }
5622
5623 //palette cycles
5624
2/2
✓ Branch 0 taken 774 times.
✓ Branch 1 taken 24 times.
798 if(Header->zelda_version < 0x193) //in 1.93+, palette cycling is saved with the palettes
5625 {
5626
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 24 times.
6168 for(int32_t i=0; i<256; i++)
5627 {
5628
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 6144 times.
24576 for(int32_t j=0; j<3; j++)
5629 {
5630 18432 temp_misc.cycles[i][j].first=0;
5631 18432 temp_misc.cycles[i][j].count=0;
5632 18432 temp_misc.cycles[i][j].speed=0;
5633 18432 }
5634 6144 }
5635
5636
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
30 if((Header->zelda_version < 0x192)||
5637
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((Header->zelda_version == 0x192)&&(Header->build<73)))
5638 {
5639 18 palcycles=16;
5640 18 }
5641
5642
2/2
✓ Branch 0 taken 1824 times.
✓ Branch 1 taken 24 times.
1848 for(int32_t i=0; i<palcycles; i++)
5643 {
5644
2/2
✓ Branch 0 taken 5472 times.
✓ Branch 1 taken 1824 times.
7296 for(int32_t j=0; j<3; j++)
5645 {
5646
1/2
✓ Branch 0 taken 5472 times.
✗ Branch 1 not taken.
5472 if(!p_getc(&temp_misc.cycles[i][j].first,f))
5647 {
5648 return qe_invalid;
5649 }
5650
5651
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5472 times.
5472 if(!p_getc(&temp_misc.cycles[i][j].count,f))
5652 {
5653 return qe_invalid;
5654 }
5655
5656
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5472 times.
5472 if(!p_getc(&temp_misc.cycles[i][j].speed,f))
5657 {
5658 return qe_invalid;
5659 }
5660 5472 }
5661 1824 }
5662 24 }
5663
5664 //Wind warps are now just another warp ring.
5665
2/2
✓ Branch 0 taken 715 times.
✓ Branch 1 taken 83 times.
798 if(s_version <= 5)
5666 {
5667
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 59 times.
83 if(Header->zelda_version > 0x192)
5668 {
5669
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 if(!p_igetw(&windwarps,f))
5670 {
5671 return qe_invalid;
5672 }
5673 59 }
5674
5675
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 83 times.
83 if (windwarps > NUM_WARP_RINGS)
5676 {
5677 return qe_invalid;
5678 }
5679
5680
2/2
✓ Branch 0 taken 665 times.
✓ Branch 1 taken 83 times.
748 for(int32_t i=0; i<windwarps; i++)
5681 {
5682
1/2
✓ Branch 0 taken 665 times.
✗ Branch 1 not taken.
665 if(s_version <= 3)
5683 {
5684
1/2
✓ Branch 0 taken 665 times.
✗ Branch 1 not taken.
665 if(!p_getc(&tempbyte,f))
5685 {
5686 return qe_invalid;
5687 }
5688
5689 665 temp_misc.warp[8].dmap[i]=tempbyte;
5690 665 }
5691 else
5692 {
5693 if(!p_igetw(&temp_misc.warp[8].dmap[i],f))
5694 {
5695 return qe_invalid;
5696 }
5697 }
5698
5699
1/2
✓ Branch 0 taken 665 times.
✗ Branch 1 not taken.
665 if(!p_getc(&temp_misc.warp[8].scr[i],f))
5700 {
5701 return qe_invalid;
5702 }
5703
5704 665 temp_misc.warp[8].size = 9;
5705
5706
1/2
✓ Branch 0 taken 665 times.
✗ Branch 1 not taken.
665 if(s_version == 5)
5707 {
5708 if(!p_getc(&tempbyte,f))
5709 {
5710 return qe_invalid;
5711 }
5712 }
5713 665 }
5714 83 }
5715
5716
5717 //triforce pieces
5718
2/2
✓ Branch 0 taken 6384 times.
✓ Branch 1 taken 798 times.
7182 for(int32_t i=0; i<triforces; i++)
5719 {
5720
1/2
✓ Branch 0 taken 6384 times.
✗ Branch 1 not taken.
6384 if(!p_getc(&temp_misc.triforce[i],f))
5721 {
5722 return qe_invalid;
5723 }
5724 6384 }
5725
5726 //misc color data
5727
2/2
✓ Branch 0 taken 715 times.
✓ Branch 1 taken 83 times.
798 if(s_version<3)
5728 {
5729
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.text,f))
5730 {
5731 return qe_invalid;
5732 }
5733
5734
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.caption,f))
5735 {
5736 return qe_invalid;
5737 }
5738
5739
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.overw_bg,f))
5740 {
5741 return qe_invalid;
5742 }
5743
5744
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.dngn_bg,f))
5745 {
5746 return qe_invalid;
5747 }
5748
5749
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.dngn_fg,f))
5750 {
5751 return qe_invalid;
5752 }
5753
5754
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.cave_fg,f))
5755 {
5756 return qe_invalid;
5757 }
5758
5759
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.bs_dk,f))
5760 {
5761 return qe_invalid;
5762 }
5763
5764
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.bs_goal,f))
5765 {
5766 return qe_invalid;
5767 }
5768
5769
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.compass_lt,f))
5770 {
5771 return qe_invalid;
5772 }
5773
5774
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.compass_dk,f))
5775 {
5776 return qe_invalid;
5777 }
5778
5779
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.subscr_bg,f))
5780 {
5781 return qe_invalid;
5782 }
5783
5784
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.triframe_color,f))
5785 {
5786 return qe_invalid;
5787 }
5788
5789
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.hero_dot,f))
5790 {
5791 return qe_invalid;
5792 }
5793
5794
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.bmap_bg,f))
5795 {
5796 return qe_invalid;
5797 }
5798
5799
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.bmap_fg,f))
5800 {
5801 return qe_invalid;
5802 }
5803
5804
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.triforce_cset,f))
5805 {
5806 return qe_invalid;
5807 }
5808
5809
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.triframe_cset,f))
5810 {
5811 return qe_invalid;
5812 }
5813
5814
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.overworld_map_cset,f))
5815 {
5816 return qe_invalid;
5817 }
5818
5819
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.dungeon_map_cset,f))
5820 {
5821 return qe_invalid;
5822 }
5823
5824
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.blueframe_cset,f))
5825 {
5826 return qe_invalid;
5827 }
5828
5829
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_igetw(&temp_misc.colors.triforce_tile,f))
5830 {
5831 return qe_invalid;
5832 }
5833
5834
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_igetw(&temp_misc.colors.triframe_tile,f))
5835 {
5836 return qe_invalid;
5837 }
5838
5839
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_igetw(&temp_misc.colors.overworld_map_tile,f))
5840 {
5841 return qe_invalid;
5842 }
5843
5844
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_igetw(&temp_misc.colors.dungeon_map_tile,f))
5845 {
5846 return qe_invalid;
5847 }
5848
5849
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_igetw(&temp_misc.colors.blueframe_tile,f))
5850 {
5851 return qe_invalid;
5852 }
5853
5854
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_igetw(&temp_misc.colors.HCpieces_tile,f))
5855 {
5856 return qe_invalid;
5857 }
5858
5859
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.HCpieces_cset,f))
5860 {
5861 return qe_invalid;
5862 }
5863
5864 83 temp_misc.colors.msgtext = 0x01;
5865
5866
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 24 times.
83 if(Header->zelda_version < 0x193)
5867 {
5868
2/2
✓ Branch 0 taken 168 times.
✓ Branch 1 taken 24 times.
192 for(int32_t i=0; i<7; i++)
5869 {
5870
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 if(!p_getc(&tempbyte,f))
5871 {
5872 return qe_invalid;
5873 }
5874 168 }
5875 24 }
5876
5877
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 77 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
83 if((Header->zelda_version == 0x192)&&(Header->build>145))
5878 {
5879
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 6 times.
1542 for(int32_t i=0; i<256; i++)
5880 {
5881
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1536 times.
1536 if(!p_getc(&tempbyte,f))
5882 {
5883 return qe_invalid;
5884 }
5885 1536 }
5886 6 }
5887
5888
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(s_version>1)
5889 {
5890 if(!p_getc(&temp_misc.colors.subscr_shadow,f))
5891 {
5892 return qe_invalid;
5893 }
5894 }
5895
5896 //save game icons
5897
3/4
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
89 if((Header->zelda_version < 0x192)||
5898
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 59 times.
65 ((Header->zelda_version == 0x192)&&(Header->build<73)))
5899 {
5900 18 icons=3;
5901 18 }
5902
5903
2/2
✓ Branch 0 taken 314 times.
✓ Branch 1 taken 83 times.
397 for(int32_t i=0; i<icons; i++)
5904 {
5905
1/2
✓ Branch 0 taken 314 times.
✗ Branch 1 not taken.
314 if(!p_igetw(&temp_misc.icons[i],f))
5906 {
5907 return qe_invalid;
5908 }
5909 314 }
5910 83 }
5911
5912
3/4
✓ Branch 0 taken 780 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
804 if((Header->zelda_version < 0x192)||
5913
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 774 times.
780 ((Header->zelda_version == 0x192)&&(Header->build<30)))
5914 {
5915 18 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5916
5917 18 return 0;
5918 }
5919
5920 //pond information
5921
2/2
✓ Branch 0 taken 774 times.
✓ Branch 1 taken 6 times.
780 if(Header->zelda_version < 0x193)
5922 {
5923
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if((Header->zelda_version == 0x192)&&(Header->build<146))
5924 {
5925 pondsize=25;
5926 }
5927
5928
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 6 times.
102 for(int32_t i=0; i<ponds; i++)
5929 {
5930
2/2
✓ Branch 0 taken 6912 times.
✓ Branch 1 taken 96 times.
7008 for(int32_t j=0; j<pondsize; j++)
5931 {
5932
1/2
✓ Branch 0 taken 6912 times.
✗ Branch 1 not taken.
6912 if(!p_getc(&tempbyte,f))
5933 {
5934 return qe_invalid;
5935
5936 }
5937 6912 }
5938 96 }
5939 6 }
5940
5941 //end string
5942
2/4
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
786 if((Header->zelda_version < 0x192)||
5943
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 774 times.
780 ((Header->zelda_version == 0x192)&&(Header->build<146)))
5944 {
5945 if(!p_getc(&tempbyte,f))
5946 {
5947 return qe_invalid;
5948 }
5949
5950 temp_misc.endstring=tempbyte;
5951
5952 if(!p_getc(&tempbyte,f))
5953 {
5954 return qe_invalid;
5955 }
5956 }
5957 else
5958 {
5959
1/2
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
780 if(!p_igetw(&temp_misc.endstring,f))
5960 {
5961 return qe_invalid;
5962 }
5963 }
5964
5965 //expansion
5966
2/2
✓ Branch 0 taken 774 times.
✓ Branch 1 taken 6 times.
780 if(Header->zelda_version < 0x193)
5967 {
5968
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if((Header->zelda_version == 0x192)&&(Header->build<73))
5969 {
5970 expansionsize=99*2;
5971 }
5972
5973
2/2
✓ Branch 0 taken 1176 times.
✓ Branch 1 taken 6 times.
1182 for(int32_t i=0; i<expansionsize; i++)
5974 {
5975
1/2
✓ Branch 0 taken 1176 times.
✗ Branch 1 not taken.
1176 if(!p_getc(&tempbyte,f))
5976 {
5977 return qe_invalid;
5978 }
5979 1176 }
5980 6 }
5981 //shops v8
5982
5983
5984
2/2
✓ Branch 0 taken 590 times.
✓ Branch 1 taken 190 times.
780 if(s_version >= 8)
5985 {
5986
2/2
✓ Branch 0 taken 2288 times.
✓ Branch 1 taken 190 times.
2478 for(int32_t i=0; i<shops; i++)
5987 {
5988
2/2
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 2288 times.
9152 for(int32_t j=0; j<3; j++)
5989 {
5990
1/2
✓ Branch 0 taken 6864 times.
✗ Branch 1 not taken.
6864 if(!p_igetw(&temp_misc.shop[i].str[j],f))
5991 return qe_invalid;
5992 6864 }
5993 2288 }
5994 190 }
5995
5996 780 memset(&temp_misc.questmisc, 0, sizeof(int32_t)*32);
5997 780 memset(&temp_misc.zscript_last_compiled_version, 0, sizeof(int32_t));
5998
5999 //v9 includes quest misc[32]
6000 // ... this has been deprecated (2024)
6001
2/2
✓ Branch 0 taken 590 times.
✓ Branch 1 taken 190 times.
780 if(s_version >= 9)
6002 {
6003
2/2
✓ Branch 0 taken 6080 times.
✓ Branch 1 taken 190 times.
6270 for ( int32_t q = 0; q < 32; q++ )
6004 {
6005
1/2
✓ Branch 0 taken 6080 times.
✗ Branch 1 not taken.
6080 if(!p_igetl(&temp_misc.questmisc[q],f))
6006 return qe_invalid;
6007 6080 }
6008 // this was string labels
6009
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if (pack_fseek(f, 32 * 128))
6010 return qe_invalid;
6011 190 }
6012
6013
2/2
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 590 times.
780 if(s_version >= 11 )
6014 {
6015
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if(!p_igetl(&temp_misc.zscript_last_compiled_version,f))
6016 return qe_invalid;
6017 190 }
6018
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 590 times.
590 else if(s_version < 11 )
6019 {
6020 590 temp_misc.zscript_last_compiled_version = -1;
6021 590 }
6022
6023 780 FFCore.quest_format[vLastCompile] = temp_misc.zscript_last_compiled_version;
6024
6025
2/2
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 590 times.
780 if(s_version >= 12)
6026 {
6027 byte spr;
6028
2/2
✓ Branch 0 taken 48640 times.
✓ Branch 1 taken 190 times.
48830 for(int32_t q = 0; q < sprMAX; ++q)
6029 {
6030
1/2
✓ Branch 0 taken 48640 times.
✗ Branch 1 not taken.
48640 if(!p_getc(&spr,f))
6031 return qe_invalid;
6032 48640 temp_misc.sprites[q] = spr;
6033 48640 }
6034 190 }
6035 else
6036 {
6037 590 memset(&(temp_misc.sprites), 0, sizeof(temp_misc.sprites));
6038 //temp_misc.sprites[sprFALL] = ;
6039 }
6040
6041
2/2
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 590 times.
780 if(s_version >= 13)
6042 {
6043
2/2
✓ Branch 0 taken 12160 times.
✓ Branch 1 taken 190 times.
12350 for(size_t q = 0; q < 64; ++q)
6044 {
6045 12160 bottletype* bt = &(temp_misc.bottle_types[q]);
6046
1/2
✓ Branch 0 taken 12160 times.
✗ Branch 1 not taken.
12160 if (!p_getstr(bt->name, sizeof(bt->name)-1, f))
6047 return qe_invalid;
6048
2/2
✓ Branch 0 taken 36480 times.
✓ Branch 1 taken 12160 times.
48640 for(size_t j = 0; j < 3; ++j)
6049 {
6050
1/2
✓ Branch 0 taken 36480 times.
✗ Branch 1 not taken.
36480 if (!p_getc(&(bt->counter[j]), f))
6051 return qe_invalid;
6052
1/2
✓ Branch 0 taken 36480 times.
✗ Branch 1 not taken.
36480 if (!p_igetw(&(bt->amount[j]), f))
6053 return qe_invalid;
6054 36480 }
6055
1/2
✓ Branch 0 taken 12160 times.
✗ Branch 1 not taken.
12160 if (!p_getc(&(bt->flags), f))
6056 return qe_invalid;
6057
1/2
✓ Branch 0 taken 12160 times.
✗ Branch 1 not taken.
12160 if (!p_getc(&(bt->next_type), f))
6058 return qe_invalid;
6059 12160 }
6060
2/2
✓ Branch 0 taken 48640 times.
✓ Branch 1 taken 190 times.
48830 for(size_t q = 0; q < 256; ++q)
6061 {
6062 48640 bottleshoptype* bst = &(temp_misc.bottle_shop_types[q]);
6063
1/2
✓ Branch 0 taken 48640 times.
✗ Branch 1 not taken.
48640 if (!pfread(bst->name, sizeof(bst->name)-1, f))
6064 return qe_invalid;
6065
2/2
✓ Branch 0 taken 145920 times.
✓ Branch 1 taken 48640 times.
194560 for(size_t j = 0; j < 3; ++j)
6066 {
6067
1/2
✓ Branch 0 taken 145920 times.
✗ Branch 1 not taken.
145920 if (!p_getc(&(bst->fill[j]), f))
6068 return qe_invalid;
6069
1/2
✓ Branch 0 taken 145920 times.
✗ Branch 1 not taken.
145920 if (!p_igetw(&(bst->comb[j]), f))
6070 return qe_invalid;
6071
1/2
✓ Branch 0 taken 145920 times.
✗ Branch 1 not taken.
145920 if (!p_getc(&(bst->cset[j]), f))
6072 return qe_invalid;
6073
1/2
✓ Branch 0 taken 145920 times.
✗ Branch 1 not taken.
145920 if (!p_igetw(&(bst->price[j]), f))
6074 return qe_invalid;
6075
1/2
✓ Branch 0 taken 145920 times.
✗ Branch 1 not taken.
145920 if (!p_igetw(&(bst->str[j]), f))
6076 return qe_invalid;
6077 145920 }
6078 48640 }
6079 190 }
6080 else
6081 {
6082
2/2
✓ Branch 0 taken 37760 times.
✓ Branch 1 taken 590 times.
38350 for(size_t q = 0; q < 64; ++q)
6083 37760 temp_misc.bottle_types[q].clear();
6084
2/2
✓ Branch 0 taken 151040 times.
✓ Branch 1 taken 590 times.
151630 for(size_t q = 0; q < 256; ++q)
6085 151040 temp_misc.bottle_shop_types[q].clear();
6086 }
6087
6088
2/2
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 590 times.
780 if(s_version >= 14)
6089 {
6090 byte msfx;
6091
2/2
✓ Branch 0 taken 48640 times.
✓ Branch 1 taken 190 times.
48830 for(int32_t q = 0; q < sfxMAX; ++q)
6092 {
6093
1/2
✓ Branch 0 taken 48640 times.
✗ Branch 1 not taken.
48640 if(!p_getc(&msfx,f))
6094 return qe_invalid;
6095 48640 temp_misc.miscsfx[q] = msfx;
6096 48640 }
6097 190 }
6098 else
6099 {
6100 590 memset(&(temp_misc.miscsfx), 0, sizeof(temp_misc.miscsfx));
6101 590 temp_misc.miscsfx[sfxBUSHGRASS] = WAV_ZN1GRASSCUT;
6102 590 temp_misc.miscsfx[sfxLOWHEART] = WAV_ER;
6103 }
6104
2/2
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 590 times.
780 if(s_version < 15)
6105 {
6106 590 temp_misc.miscsfx[sfxHURTPLAYER] = WAV_OUCH;
6107 590 temp_misc.miscsfx[sfxHAMMERPOUND] = WAV_ZN1HAMMERPOST;
6108 590 temp_misc.miscsfx[sfxSUBSCR_ITEM_ASSIGN] = WAV_PLACE;
6109 590 temp_misc.miscsfx[sfxSUBSCR_CURSOR_MOVE] = WAV_CHIME;
6110 590 temp_misc.miscsfx[sfxREFILL] = WAV_MSG;
6111 590 temp_misc.miscsfx[sfxDRAIN] = WAV_MSG;
6112 590 }
6113
2/2
✓ Branch 0 taken 173 times.
✓ Branch 1 taken 607 times.
780 if(s_version < 16)
6114 {
6115 607 temp_misc.miscsfx[sfxTAP] = WAV_ZN1TAP;
6116 607 temp_misc.miscsfx[sfxTAP_HOLLOW] = WAV_ZN1TAP2;
6117 607 }
6118
6119
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 779 times.
780 if (!should_skip)
6120 779 memcpy(Misc, &temp_misc, sizeof(temp_misc));
6121
6122 780 return 0;
6123 798 }
6124
6125 extern char *item_string[MAXITEMS];
6126 extern const char *old_item_string[iLast];
6127 extern char *weapon_string[MAXWPNS];
6128 extern const char *old_weapon_string[wLast];
6129
6130 478 int32_t readitems(PACKFILE *f, word version, word build)
6131 {
6132
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 454 times.
478 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_items);
6133
6134 byte padding;
6135 int32_t dummy;
6136 478 word items_to_read=MAXITEMS;
6137 478 itemdata tempitem;
6138 478 word s_version=0;
6139 word dummy_word;
6140
6141
2/2
✓ Branch 0 taken 472 times.
✓ Branch 1 taken 6 times.
478 if(version < 0x186)
6142 {
6143 6 items_to_read=64;
6144 6 }
6145
6146
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 454 times.
478 if(version > 0x192)
6147 {
6148 454 items_to_read=0;
6149
6150 //section version info
6151
1/2
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
454 if(!p_igetw(&s_version,f))
6152 {
6153 return qe_invalid;
6154 }
6155
6156 454 FFCore.quest_format[vItems] = s_version;
6157
6158
1/2
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
454 if(!read_deprecated_section_cversion(f))
6159 {
6160 return qe_invalid;
6161 }
6162
6163 //section size
6164
1/2
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
454 if(!p_igetl(&dummy,f))
6165 {
6166 return qe_invalid;
6167 }
6168
6169 //finally... section data
6170
1/2
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
454 if(!p_igetw(&items_to_read,f))
6171 {
6172 return qe_invalid;
6173 }
6174
6175
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 454 times.
454 if (items_to_read > MAXITEMS)
6176 {
6177 return qe_invalid;
6178 }
6179 454 }
6180
6181
2/2
✓ Branch 0 taken 395 times.
✓ Branch 1 taken 83 times.
478 if(s_version>1)
6182 {
6183
2/2
✓ Branch 0 taken 101120 times.
✓ Branch 1 taken 395 times.
101515 for(int32_t i=0; i<items_to_read; i++)
6184 {
6185 char tempname[64];
6186
6187
1/2
✓ Branch 0 taken 101120 times.
✗ Branch 1 not taken.
101120 if(!pfread(tempname, 64, f))
6188 {
6189 return qe_invalid;
6190 }
6191
6192 101120 item_string[i][0] = '\0';
6193 101120 strncat(item_string[i], tempname, 64 - 1);
6194 101120 }
6195 395 }
6196
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 82 times.
83 else if (!should_skip)
6197 {
6198
2/2
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 82 times.
21074 for(int32_t i=0; i<MAXITEMS; i++)
6199 {
6200 20992 reset_itemname(i);
6201 20992 }
6202 82 }
6203
6204
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 477 times.
478 if (!should_skip)
6205
2/2
✓ Branch 0 taken 122112 times.
✓ Branch 1 taken 477 times.
122589 for(int32_t i=0; i<MAXITEMS; i++)
6206 {
6207 122112 itemdata& id = itemsbuf[i];
6208 122112 memset(&id, 0, sizeof(itemdata));
6209 122112 id.count=-1;
6210 122112 id.playsound=WAV_SCALE;
6211 122112 reset_itembuf(&id,i);
6212 122589 }
6213
6214
2/2
✓ Branch 0 taken 110242 times.
✓ Branch 1 taken 478 times.
110720 for(int32_t i=0; i<items_to_read; i++)
6215 {
6216 110242 tempitem = itemdata();
6217 110242 reset_itembuf(&tempitem,i);
6218
6219
2/2
✓ Branch 0 taken 48640 times.
✓ Branch 1 taken 61602 times.
110242 if ( s_version > 35 ) //expanded tiles
6220 {
6221
1/2
✓ Branch 0 taken 48640 times.
✗ Branch 1 not taken.
48640 if(!p_igetl(&tempitem.tile,f))
6222 {
6223 return qe_invalid;
6224 }
6225 48640 }
6226 else
6227 {
6228
1/2
✓ Branch 0 taken 61602 times.
✗ Branch 1 not taken.
61602 if(!p_igetw(&tempitem.tile,f))
6229 {
6230 return qe_invalid;
6231 }
6232 }
6233
6234
1/2
✓ Branch 0 taken 110242 times.
✗ Branch 1 not taken.
110242 if(!p_getc(&tempitem.misc_flags,f))
6235 {
6236 return qe_invalid;
6237 }
6238
6239
1/2
✓ Branch 0 taken 110242 times.
✗ Branch 1 not taken.
110242 if(!p_getc(&tempitem.csets,f))
6240 {
6241 return qe_invalid;
6242 }
6243
6244
1/2
✓ Branch 0 taken 110242 times.
✗ Branch 1 not taken.
110242 if(!p_getc(&tempitem.frames,f))
6245 {
6246 return qe_invalid;
6247 }
6248
6249
1/2
✓ Branch 0 taken 110242 times.
✗ Branch 1 not taken.
110242 if(!p_getc(&tempitem.speed,f))
6250 {
6251 return qe_invalid;
6252 }
6253
6254
1/2
✓ Branch 0 taken 110242 times.
✗ Branch 1 not taken.
110242 if(!p_getc(&tempitem.delay,f))
6255 {
6256 return qe_invalid;
6257 }
6258
6259
2/2
✓ Branch 0 taken 105250 times.
✓ Branch 1 taken 4992 times.
110242 if(version < 0x193)
6260 {
6261
1/2
✓ Branch 0 taken 4992 times.
✗ Branch 1 not taken.
4992 if(!p_getc(&padding,f))
6262 {
6263 return qe_invalid;
6264 }
6265
6266
4/6
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 3456 times.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1536 times.
✗ Branch 5 not taken.
4992 if((version < 0x192)||((version == 0x192)&&(build<186)))
6267 {
6268
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 4736 times.
4992 if (should_skip)
6269 256 continue;
6270
6271
3/3
✓ Branch 0 taken 4690 times.
✓ Branch 1 taken 23 times.
✓ Branch 2 taken 23 times.
4736 switch(i)
6272 {
6273 case iShield:
6274 23 tempitem.ltm=get_qr(qr_BSZELDA)?-12:10;
6275 23 break;
6276
6277 case iMShield:
6278 23 tempitem.ltm=get_qr(qr_BSZELDA)?-6:-10;
6279 23 break;
6280
6281 default:
6282 4690 tempitem.ltm=0;
6283 4690 break;
6284 }
6285
6286 4736 tempitem.count=-1;
6287 4736 tempitem.flags=item_none;
6288 4736 tempitem.wpn=tempitem.wpn2=tempitem.wpn3=tempitem.wpn3=tempitem.pickup_hearts=
6289 4736 tempitem.misc1=tempitem.misc2=tempitem.usesound=0;
6290 4736 tempitem.family=0xFF;
6291 4736 tempitem.playsound=WAV_SCALE;
6292 4736 reset_itembuf(&tempitem,i);
6293
6294 4736 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
6295
6296 4736 continue;
6297 }
6298 }
6299
6300
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105250 times.
105250 if(!p_igetl(&tempitem.ltm,f))
6301 {
6302 return qe_invalid;
6303 }
6304
6305
1/2
✓ Branch 0 taken 105250 times.
✗ Branch 1 not taken.
105250 if(version < 0x193)
6306 {
6307 for(int32_t q=0; q<12; q++)
6308 {
6309 if(!p_getc(&padding,f))
6310 {
6311 return qe_invalid;
6312 }
6313 }
6314 }
6315
6316
2/2
✓ Branch 0 taken 101120 times.
✓ Branch 1 taken 4130 times.
105250 if(s_version>1)
6317 {
6318
2/2
✓ Branch 0 taken 48640 times.
✓ Branch 1 taken 52480 times.
101120 if ( s_version >= 31 )
6319 {
6320
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48640 times.
48640 if(!p_igetl(&tempitem.family,f))
6321 {
6322 return qe_invalid;
6323 }
6324 48640 }
6325 else
6326 {
6327
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52480 times.
52480 if(!p_getc(&tempitem.family,f))
6328 {
6329 return qe_invalid;
6330 }
6331 }
6332
1/2
✓ Branch 0 taken 101120 times.
✗ Branch 1 not taken.
101120 if(s_version < 16)
6333 if(tempitem.family == 0xFF)
6334 tempitem.family = itype_misc;
6335
6336
1/2
✓ Branch 0 taken 101120 times.
✗ Branch 1 not taken.
101120 if(!p_getc(&tempitem.fam_type,f))
6337 {
6338 return qe_invalid;
6339 }
6340
6341
1/2
✓ Branch 0 taken 101120 times.
✗ Branch 1 not taken.
101120 if(s_version>5)
6342 {
6343
2/2
✓ Branch 0 taken 48640 times.
✓ Branch 1 taken 52480 times.
101120 if(s_version>=31)
6344 {
6345
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48640 times.
48640 if(!p_igetl(&tempitem.power,f))
6346 {
6347 return qe_invalid;
6348 }
6349 48640 }
6350 else
6351 {
6352
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52480 times.
52480 if(!p_getc(&tempitem.power,f))
6353 {
6354 return qe_invalid;
6355 }
6356 }
6357
6358 //converted flags from 16b to 32b -Z
6359
2/2
✓ Branch 0 taken 52480 times.
✓ Branch 1 taken 48640 times.
101120 if ( s_version < 41 )
6360 {
6361
1/2
✓ Branch 0 taken 52480 times.
✗ Branch 1 not taken.
52480 if(!p_igetw(&tempitem.flags,f))
6362 {
6363 return qe_invalid;
6364 }
6365 52480 }
6366 else
6367 {
6368
1/2
✓ Branch 0 taken 48640 times.
✗ Branch 1 not taken.
48640 if(!p_igetl(&tempitem.flags,f))
6369 {
6370 return qe_invalid;
6371 }
6372 }
6373 101120 }
6374 else
6375 {
6376 //tempitem.power = tempitem.fam_type;
6377 char tempchar;
6378
6379 if(!p_getc(&tempchar,f))
6380 {
6381 return qe_invalid;
6382 }
6383
6384 if (tempchar) tempitem.flags |= item_gamedata;
6385 }
6386
6387
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101120 times.
101120 if(!p_igetw(&tempitem.script,f))
6388 {
6389 return qe_invalid;
6390 }
6391
6392
1/2
✓ Branch 0 taken 101120 times.
✗ Branch 1 not taken.
101120 if(s_version<=3)
6393 {
6394 if(tempitem.script > NUMSCRIPTITEM)
6395 {
6396 tempitem.script = 0;
6397 }
6398 }
6399
6400
1/2
✓ Branch 0 taken 101120 times.
✗ Branch 1 not taken.
101120 if(!p_getc(&tempitem.count,f))
6401 {
6402 return qe_invalid;
6403 }
6404
6405
1/2
✓ Branch 0 taken 101120 times.
✗ Branch 1 not taken.
101120 if(!p_igetw(&tempitem.amount,f))
6406 {
6407 return qe_invalid;
6408 }
6409
6410
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101120 times.
101120 if(!p_igetw(&tempitem.collect_script,f))
6411 {
6412 return qe_invalid;
6413 }
6414
6415
1/2
✓ Branch 0 taken 101120 times.
✗ Branch 1 not taken.
101120 if(s_version<=3)
6416 {
6417 if(tempitem.collect_script > NUMSCRIPTITEM)
6418 {
6419 tempitem.collect_script = 0;
6420 }
6421 }
6422
6423
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101120 times.
101120 if(!p_igetw(&tempitem.setmax,f))
6424 {
6425 return qe_invalid;
6426 }
6427
6428
1/2
✓ Branch 0 taken 101120 times.
✗ Branch 1 not taken.
101120 if(!p_igetw(&tempitem.max,f))
6429 {
6430 return qe_invalid;
6431 }
6432
6433
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101120 times.
101120 if(!p_getc(&tempitem.playsound,f))
6434 {
6435 return qe_invalid;
6436 }
6437
6438
2/2
✓ Branch 0 taken 808960 times.
✓ Branch 1 taken 101120 times.
910080 for(int32_t j=0; j<8; j++)
6439 {
6440
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 808960 times.
808960 if(!p_igetl(&tempitem.initiald[j],f))
6441 {
6442 return qe_invalid;
6443 }
6444 808960 }
6445
6446
2/2
✓ Branch 0 taken 202240 times.
✓ Branch 1 taken 101120 times.
303360 for(int32_t j=0; j<2; j++)
6447 {
6448 byte temp;
6449
1/2
✓ Branch 0 taken 202240 times.
✗ Branch 1 not taken.
202240 if(!p_getc(&temp,f))
6450 {
6451 return qe_invalid;
6452 }
6453 202240 }
6454
6455
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101120 times.
101120 if(s_version>4)
6456 {
6457
1/2
✓ Branch 0 taken 101120 times.
✗ Branch 1 not taken.
101120 if(s_version>5)
6458 {
6459
1/2
✓ Branch 0 taken 101120 times.
✗ Branch 1 not taken.
101120 if(!p_getc(&tempitem.wpn,f))
6460 {
6461 return qe_invalid;
6462 }
6463
6464
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101120 times.
101120 if(!p_getc(&tempitem.wpn2,f))
6465 {
6466 return qe_invalid;
6467 }
6468
6469
1/2
✓ Branch 0 taken 101120 times.
✗ Branch 1 not taken.
101120 if(!p_getc(&tempitem.wpn3,f))
6470 {
6471 return qe_invalid;
6472 }
6473
6474
1/2
✓ Branch 0 taken 101120 times.
✗ Branch 1 not taken.
101120 if(!p_getc(&tempitem.wpn4,f))
6475 {
6476 return qe_invalid;
6477 }
6478
6479
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101120 times.
101120 if(s_version>=15)
6480 {
6481
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101120 times.
101120 if(!p_getc(&tempitem.wpn5,f))
6482 {
6483 return qe_invalid;
6484 }
6485
6486
1/2
✓ Branch 0 taken 101120 times.
✗ Branch 1 not taken.
101120 if(!p_getc(&tempitem.wpn6,f))
6487 {
6488 return qe_invalid;
6489 }
6490
6491
1/2
✓ Branch 0 taken 101120 times.
✗ Branch 1 not taken.
101120 if(!p_getc(&tempitem.wpn7,f))
6492 {
6493 return qe_invalid;
6494 }
6495
6496
1/2
✓ Branch 0 taken 101120 times.
✗ Branch 1 not taken.
101120 if(!p_getc(&tempitem.wpn8,f))
6497 {
6498 return qe_invalid;
6499 }
6500
6501
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101120 times.
101120 if(!p_getc(&tempitem.wpn9,f))
6502 {
6503 return qe_invalid;
6504 }
6505
6506
1/2
✓ Branch 0 taken 101120 times.
✗ Branch 1 not taken.
101120 if(!p_getc(&tempitem.wpn10,f))
6507 {
6508 return qe_invalid;
6509 }
6510 101120 }
6511
6512
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101120 times.
101120 if(!p_getc(&tempitem.pickup_hearts,f))
6513 {
6514 return qe_invalid;
6515 }
6516
6517
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101120 times.
101120 if(s_version<15)
6518 {
6519 if(!p_igetw(&dummy_word,f))
6520 {
6521 return qe_invalid;
6522 }
6523
6524 tempitem.misc1=dummy_word;
6525
6526 if(!p_igetw(&dummy_word,f))
6527 {
6528 return qe_invalid;
6529 }
6530
6531 tempitem.misc2=dummy_word;
6532 }
6533 else
6534 {
6535
1/2
✓ Branch 0 taken 101120 times.
✗ Branch 1 not taken.
101120 if(!p_igetl(&tempitem.misc1,f))
6536 {
6537 return qe_invalid;
6538 }
6539
6540
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101120 times.
101120 if(!p_igetl(&tempitem.misc2,f))
6541 {
6542 return qe_invalid;
6543 }
6544
6545 // Version 24: sh_ice -> sh_script; previously, all shields could block script weapons
6546
1/2
✓ Branch 0 taken 101120 times.
✗ Branch 1 not taken.
101120 if(s_version<24)
6547 {
6548 if(tempitem.family==itype_shield)
6549 {
6550 tempitem.misc1|=sh_script;
6551 }
6552 }
6553 }
6554
6555
2/2
✓ Branch 0 taken 52480 times.
✓ Branch 1 taken 48640 times.
101120 if(s_version < 53)
6556 {
6557 byte tempbyte;
6558
1/2
✓ Branch 0 taken 52480 times.
✗ Branch 1 not taken.
52480 if(!p_getc(&tempbyte,f))
6559 {
6560 return qe_invalid;
6561 }
6562 52480 tempitem.cost_amount[0] = tempbyte;
6563 52480 }
6564 else
6565 {
6566
2/2
✓ Branch 0 taken 97280 times.
✓ Branch 1 taken 48640 times.
145920 for(auto q = 0; q < 2; ++q)
6567 {
6568
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97280 times.
97280 if(!p_igetw(&tempitem.cost_amount[q],f))
6569 {
6570 return qe_invalid;
6571 }
6572 97280 }
6573 }
6574 101120 }
6575 else
6576 {
6577 char tempchar;
6578
6579 if(!p_getc(&tempchar,f))
6580 {
6581 return qe_invalid;
6582 }
6583
6584 if (tempchar) tempitem.flags |= item_edible;
6585 }
6586
6587 // June 2007: more misc. attributes
6588
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101120 times.
101120 if(s_version>=12)
6589 {
6590
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101120 times.
101120 if(s_version<15)
6591 {
6592 if(!p_igetw(&dummy_word,f))
6593 {
6594 return qe_invalid;
6595 }
6596
6597 tempitem.misc3=dummy_word;
6598
6599 if(!p_igetw(&dummy_word,f))
6600 {
6601 return qe_invalid;
6602 }
6603
6604 tempitem.misc4=dummy_word;
6605 }
6606 else
6607 {
6608
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101120 times.
101120 if(!p_igetl(&tempitem.misc3,f))
6609 {
6610 return qe_invalid;
6611 }
6612
6613
1/2
✓ Branch 0 taken 101120 times.
✗ Branch 1 not taken.
101120 if(!p_igetl(&tempitem.misc4,f))
6614 {
6615 return qe_invalid;
6616 }
6617
6618
1/2
✓ Branch 0 taken 101120 times.
✗ Branch 1 not taken.
101120 if(!p_igetl(&tempitem.misc5,f))
6619 {
6620 return qe_invalid;
6621 }
6622
6623
1/2
✓ Branch 0 taken 101120 times.
✗ Branch 1 not taken.
101120 if(!p_igetl(&tempitem.misc6,f))
6624 {
6625 return qe_invalid;
6626 }
6627
6628
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101120 times.
101120 if(!p_igetl(&tempitem.misc7,f))
6629 {
6630 return qe_invalid;
6631 }
6632
6633
1/2
✓ Branch 0 taken 101120 times.
✗ Branch 1 not taken.
101120 if(!p_igetl(&tempitem.misc8,f))
6634 {
6635 return qe_invalid;
6636 }
6637
6638
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101120 times.
101120 if(!p_igetl(&tempitem.misc9,f))
6639 {
6640 return qe_invalid;
6641 }
6642
6643
1/2
✓ Branch 0 taken 101120 times.
✗ Branch 1 not taken.
101120 if(!p_igetl(&tempitem.misc10,f))
6644 {
6645 return qe_invalid;
6646 }
6647 }
6648
6649
1/2
✓ Branch 0 taken 101120 times.
✗ Branch 1 not taken.
101120 if(!p_getc(&tempitem.usesound,f))
6650 {
6651 return qe_invalid;
6652 }
6653
6654
2/2
✓ Branch 0 taken 48640 times.
✓ Branch 1 taken 52480 times.
101120 if(s_version >= 49)
6655 {
6656
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48640 times.
48640 if(!p_getc(&tempitem.usesound2,f))
6657 {
6658 return qe_invalid;
6659 }
6660 48640 }
6661 52480 else tempitem.usesound2 = 0;
6662
6663
3/4
✓ Branch 0 taken 52480 times.
✓ Branch 1 taken 48640 times.
✓ Branch 2 taken 52480 times.
✗ Branch 3 not taken.
101120 if(s_version < 50 && tempitem.family == itype_mirror)
6664 {
6665 //Split continue/dmap warp effect/sfx, port for old
6666 tempitem.misc2 = tempitem.misc1;
6667 tempitem.usesound2 = tempitem.usesound;
6668 }
6669 101120 }
6670 101120 }
6671
6672
2/2
✓ Branch 0 taken 52480 times.
✓ Branch 1 taken 48640 times.
101120 if ( s_version >= 26 ) //! New itemdata vars for weapon editor. -Z
6673 { // temp.useweapon, temp.usedefence, temp.weaprange, temp.weap_pattern[ITEM_MOVEMENT_PATTERNS]
6674
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48640 times.
48640 if(!p_getc(&tempitem.useweapon,f))
6675 {
6676 return qe_invalid;
6677 }
6678
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48640 times.
48640 if(!p_getc(&tempitem.usedefense,f))
6679 {
6680 return qe_invalid;
6681 }
6682
1/2
✓ Branch 0 taken 48640 times.
✗ Branch 1 not taken.
48640 if(!p_igetl(&tempitem.weaprange,f))
6683 {
6684 return qe_invalid;
6685 }
6686
1/2
✓ Branch 0 taken 48640 times.
✗ Branch 1 not taken.
48640 if(!p_igetl(&tempitem.weapduration,f))
6687 {
6688 return qe_invalid;
6689 }
6690
2/2
✓ Branch 0 taken 486400 times.
✓ Branch 1 taken 48640 times.
535040 for ( int32_t q = 0; q < ITEM_MOVEMENT_PATTERNS; q++ )
6691 {
6692
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 486400 times.
486400 if(!p_igetl(&tempitem.weap_pattern[q],f))
6693 {
6694 return qe_invalid;
6695 }
6696 486400 }
6697 48640 }
6698
6699
2/2
✓ Branch 0 taken 52480 times.
✓ Branch 1 taken 48640 times.
101120 if ( s_version >= 27 ) //! New itemdata vars for weapon editor. -Z
6700 { // temp.useweapon, temp.usedefence, temp.weaprange, temp.weap_pattern[ITEM_MOVEMENT_PATTERNS]
6701
1/2
✓ Branch 0 taken 48640 times.
✗ Branch 1 not taken.
48640 if(!p_igetl(&tempitem.duplicates,f))
6702 {
6703 return qe_invalid;
6704 }
6705
2/2
✓ Branch 0 taken 389120 times.
✓ Branch 1 taken 48640 times.
437760 for ( int32_t q = 0; q < INITIAL_D; q++ )
6706 {
6707
1/2
✓ Branch 0 taken 389120 times.
✗ Branch 1 not taken.
389120 if(!p_igetl(&tempitem.weap_initiald[q],f))
6708 {
6709 return qe_invalid;
6710 }
6711 389120 }
6712
2/2
✓ Branch 0 taken 97280 times.
✓ Branch 1 taken 48640 times.
145920 for ( int32_t q = 0; q < 2; q++ )
6713 {
6714 byte temp;
6715
1/2
✓ Branch 0 taken 97280 times.
✗ Branch 1 not taken.
97280 if(!p_getc(&temp,f))
6716 {
6717 return qe_invalid;
6718 }
6719 97280 }
6720
6721
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48640 times.
48640 if(!p_getc(&tempitem.drawlayer,f))
6722 {
6723 return qe_invalid;
6724 }
6725
6726
6727
1/2
✓ Branch 0 taken 48640 times.
✗ Branch 1 not taken.
48640 if(!p_igetl(&tempitem.hxofs,f))
6728 {
6729 return qe_invalid;
6730 }
6731
1/2
✓ Branch 0 taken 48640 times.
✗ Branch 1 not taken.
48640 if(!p_igetl(&tempitem.hyofs,f))
6732 {
6733 return qe_invalid;
6734 }
6735
1/2
✓ Branch 0 taken 48640 times.
✗ Branch 1 not taken.
48640 if(!p_igetl(&tempitem.hxsz,f))
6736 {
6737 return qe_invalid;
6738 }
6739
1/2
✓ Branch 0 taken 48640 times.
✗ Branch 1 not taken.
48640 if(!p_igetl(&tempitem.hysz,f))
6740 {
6741 return qe_invalid;
6742 }
6743
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48640 times.
48640 if(!p_igetl(&tempitem.hzsz,f))
6744 {
6745 return qe_invalid;
6746 }
6747
1/2
✓ Branch 0 taken 48640 times.
✗ Branch 1 not taken.
48640 if(!p_igetl(&tempitem.xofs,f))
6748 {
6749 return qe_invalid;
6750 }
6751
1/2
✓ Branch 0 taken 48640 times.
✗ Branch 1 not taken.
48640 if(!p_igetl(&tempitem.yofs,f))
6752 {
6753 return qe_invalid;
6754 }
6755
1/2
✓ Branch 0 taken 48640 times.
✗ Branch 1 not taken.
48640 if(!p_igetl(&tempitem.weap_hxofs,f))
6756 {
6757 return qe_invalid;
6758 }
6759
1/2
✓ Branch 0 taken 48640 times.
✗ Branch 1 not taken.
48640 if(!p_igetl(&tempitem.weap_hyofs,f))
6760 {
6761 return qe_invalid;
6762 }
6763
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48640 times.
48640 if(!p_igetl(&tempitem.weap_hxsz,f))
6764 {
6765 return qe_invalid;
6766 }
6767
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48640 times.
48640 if(!p_igetl(&tempitem.weap_hysz,f))
6768 {
6769 return qe_invalid;
6770 }
6771
1/2
✓ Branch 0 taken 48640 times.
✗ Branch 1 not taken.
48640 if(!p_igetl(&tempitem.weap_hzsz,f))
6772 {
6773 return qe_invalid;
6774 }
6775
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48640 times.
48640 if(!p_igetl(&tempitem.weap_xofs,f))
6776 {
6777 return qe_invalid;
6778 }
6779
1/2
✓ Branch 0 taken 48640 times.
✗ Branch 1 not taken.
48640 if(!p_igetl(&tempitem.weap_yofs,f))
6780 {
6781 return qe_invalid;
6782 }
6783
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48640 times.
48640 if(!p_igetw(&tempitem.weaponscript,f))
6784 {
6785 return qe_invalid;
6786 }
6787
1/2
✓ Branch 0 taken 48640 times.
✗ Branch 1 not taken.
48640 if(!p_igetl(&tempitem.wpnsprite,f))
6788 {
6789 return qe_invalid;
6790 }
6791 48640 auto num_cost_tmr = (s_version > 52 ? 2 : 1);
6792
2/2
✓ Branch 0 taken 97280 times.
✓ Branch 1 taken 48640 times.
145920 for(auto q = 0; q < num_cost_tmr; ++q)
6793 {
6794
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97280 times.
97280 if(!p_igetl(&tempitem.magiccosttimer[q],f))
6795 {
6796 return qe_invalid;
6797 }
6798 97280 }
6799
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48640 times.
48640 for(auto q = num_cost_tmr; q < 2; ++q)
6800 tempitem.magiccosttimer[q] = 0;
6801 48640 }
6802
2/2
✓ Branch 0 taken 52480 times.
✓ Branch 1 taken 48640 times.
101120 if ( s_version >= 28 ) //! New itemdata vars for weapon editor. -Z
6803 {
6804 //Item Size FLags, TileWidth, TileHeight
6805
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48640 times.
48640 if(!p_igetl(&tempitem.overrideFLAGS,f))
6806 {
6807 return qe_invalid;
6808 }
6809
1/2
✓ Branch 0 taken 48640 times.
✗ Branch 1 not taken.
48640 if(!p_igetl(&tempitem.tilew,f))
6810 {
6811 return qe_invalid;
6812 }
6813
1/2
✓ Branch 0 taken 48640 times.
✗ Branch 1 not taken.
48640 if(!p_igetl(&tempitem.tileh,f))
6814 {
6815 return qe_invalid;
6816 }
6817 48640 }
6818
2/2
✓ Branch 0 taken 52480 times.
✓ Branch 1 taken 48640 times.
101120 if ( s_version >= 29 ) //! More new vars.
6819 {
6820 //Item Size FLags, TileWidth, TileHeight
6821
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48640 times.
48640 if(!p_igetl(&tempitem.weapoverrideFLAGS,f))
6822 {
6823 return qe_invalid;
6824 }
6825
1/2
✓ Branch 0 taken 48640 times.
✗ Branch 1 not taken.
48640 if(!p_igetl(&tempitem.weap_tilew,f))
6826 {
6827 return qe_invalid;
6828 }
6829
1/2
✓ Branch 0 taken 48640 times.
✗ Branch 1 not taken.
48640 if(!p_igetl(&tempitem.weap_tileh,f))
6830 {
6831 return qe_invalid;
6832 }
6833 48640 }
6834
2/2
✓ Branch 0 taken 52480 times.
✓ Branch 1 taken 48640 times.
101120 if ( s_version >= 30 ) //! More new vars.
6835 {
6836 //Pickup Type
6837
1/2
✓ Branch 0 taken 48640 times.
✗ Branch 1 not taken.
48640 if(!p_igetl(&tempitem.pickup,f))
6838 {
6839 return qe_invalid;
6840 }
6841 48640 }
6842
2/2
✓ Branch 0 taken 52480 times.
✓ Branch 1 taken 48640 times.
101120 if ( s_version >= 32 ) //! More new vars.
6843 {
6844 //Pickup Type
6845
1/2
✓ Branch 0 taken 48640 times.
✗ Branch 1 not taken.
48640 if(!p_igetw(&tempitem.pstring,f))
6846 {
6847 return qe_invalid;
6848 }
6849 48640 }
6850
2/2
✓ Branch 0 taken 52480 times.
✓ Branch 1 taken 48640 times.
101120 if ( s_version >= 33 ) //! More new vars.
6851 {
6852 //Pickup Type
6853
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48640 times.
48640 if(!p_igetw(&tempitem.pickup_string_flags,f))
6854 {
6855 return qe_invalid;
6856 }
6857 48640 }
6858
2/2
✓ Branch 0 taken 52480 times.
✓ Branch 1 taken 48640 times.
101120 if ( s_version >= 34 ) //! cost counter
6859 {
6860
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48640 times.
48640 if(s_version < 53)
6861 {
6862 if(!p_getc(&tempitem.cost_counter[0],f))
6863 {
6864 return qe_invalid;
6865 }
6866 }
6867 else
6868 {
6869
2/2
✓ Branch 0 taken 97280 times.
✓ Branch 1 taken 48640 times.
145920 for(auto q = 0; q < 2; ++q)
6870 {
6871
1/2
✓ Branch 0 taken 97280 times.
✗ Branch 1 not taken.
97280 if(!p_getc(&tempitem.cost_counter[q],f))
6872 {
6873 return qe_invalid;
6874 }
6875 97280 }
6876 }
6877 48640 }
6878
2/2
✓ Branch 0 taken 52480 times.
✓ Branch 1 taken 48640 times.
101120 if ( s_version >= 44 ) //! sprite scripts
6879 {
6880
2/2
✓ Branch 0 taken 389120 times.
✓ Branch 1 taken 48640 times.
437760 for ( int32_t q = 0; q < 8; q++ )
6881 {
6882
2/2
✓ Branch 0 taken 25292800 times.
✓ Branch 1 taken 389120 times.
25681920 for ( int32_t w = 0; w < 65; w++ )
6883 {
6884
1/2
✓ Branch 0 taken 25292800 times.
✗ Branch 1 not taken.
25292800 if(!p_getc(&(tempitem.initD_label[q][w]),f))
6885 {
6886 return qe_invalid;
6887 }
6888 25292800 }
6889
2/2
✓ Branch 0 taken 25292800 times.
✓ Branch 1 taken 389120 times.
25681920 for ( int32_t w = 0; w < 65; w++ )
6890 {
6891
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25292800 times.
25292800 if(!p_getc(&(tempitem.weapon_initD_label[q][w]),f))
6892 {
6893 return qe_invalid;
6894 }
6895 25292800 }
6896
2/2
✓ Branch 0 taken 25292800 times.
✓ Branch 1 taken 389120 times.
25681920 for ( int32_t w = 0; w < 65; w++ )
6897 {
6898
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25292800 times.
25292800 if(!p_getc(&(tempitem.sprite_initD_label[q][w]),f))
6899 {
6900 return qe_invalid;
6901 }
6902 25292800 }
6903
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 389120 times.
389120 if(!p_igetl(&(tempitem.sprite_initiald[q]),f))
6904 {
6905 return qe_invalid;
6906 }
6907
6908 389120 }
6909
2/2
✓ Branch 0 taken 97280 times.
✓ Branch 1 taken 48640 times.
145920 for ( int32_t q = 0; q < 2; q++ )
6910 {
6911 byte temp;
6912
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97280 times.
97280 if(!p_getc(&temp,f))
6913 {
6914 return qe_invalid;
6915 }
6916 97280 }
6917 //Pickup Type
6918
1/2
✓ Branch 0 taken 48640 times.
✗ Branch 1 not taken.
48640 if(!p_igetw(&tempitem.sprite_script,f))
6919 {
6920 return qe_invalid;
6921 }
6922 48640 }
6923
2/2
✓ Branch 0 taken 52480 times.
✓ Branch 1 taken 48640 times.
101120 if ( s_version >= 48 ) //! pickup flags
6924 {
6925
1/2
✓ Branch 0 taken 48640 times.
✗ Branch 1 not taken.
48640 if(!p_getc(&(tempitem.pickupflag),f))
6926 {
6927 return qe_invalid;
6928 }
6929 48640 }
6930
2/2
✓ Branch 0 taken 55808 times.
✓ Branch 1 taken 45312 times.
101120 if ( s_version >= 57 )
6931 {
6932 45312 std::string str;
6933
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 45312 times.
✓ Branch 2 taken 45312 times.
✗ Branch 3 not taken.
45312 if(!p_getcstr(&str,f))
6934 return qe_invalid;
6935 45312 strncpy(tempitem.display_name,str.c_str(),255);
6936
1/3
✓ Branch 0 taken 45312 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
45312 }
6937 101120 }
6938 else
6939 {
6940 4130 tempitem.count=-1;
6941 4130 tempitem.family=itype_misc;
6942 4130 tempitem.flags=item_none;
6943 4130 tempitem.wpn=tempitem.wpn2=tempitem.wpn3=tempitem.wpn3=tempitem.pickup_hearts=tempitem.misc1=tempitem.misc2=tempitem.usesound=0;
6944 4130 tempitem.playsound=WAV_SCALE;
6945 4130 reset_itembuf(&tempitem,i);
6946 }
6947
6948
2/2
✓ Branch 0 taken 60962 times.
✓ Branch 1 taken 44288 times.
105250 if(s_version >= 58)
6949 {
6950
2/2
✓ Branch 0 taken 221440 times.
✓ Branch 1 taken 44288 times.
265728 for(int q = 0; q < WPNSPR_MAX; ++q)
6951 {
6952
1/2
✓ Branch 0 taken 221440 times.
✗ Branch 1 not taken.
221440 if(!p_getc(&tempitem.burnsprs[q],f))
6953 return qe_invalid;
6954
2/2
✓ Branch 0 taken 1280 times.
✓ Branch 1 taken 220160 times.
221440 if(s_version >= 59)
6955
1/2
✓ Branch 0 taken 220160 times.
✗ Branch 1 not taken.
220160 if(!p_getc(&tempitem.light_rads[q],f))
6956 return qe_invalid;
6957 221440 }
6958 44288 }
6959
6960
2/2
✓ Branch 0 taken 72738 times.
✓ Branch 1 taken 32512 times.
105250 if ( s_version >= 60 )
6961 {
6962
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32512 times.
32512 if(!p_getc(&tempitem.pickup_litems,f))
6963 return qe_invalid;
6964
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32512 times.
32512 if(!p_igetw(&tempitem.pickup_litem_level,f))
6965 return qe_invalid;
6966 32512 }
6967
6968
2/2
✓ Branch 0 taken 32256 times.
✓ Branch 1 taken 72994 times.
105250 if ( s_version >= 62 )
6969 {
6970
1/2
✓ Branch 0 taken 32256 times.
✗ Branch 1 not taken.
32256 if (!p_igetl(&tempitem.moveflags, f))
6971 return qe_invalid;
6972
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32256 times.
32256 if (!p_igetl(&tempitem.wmoveflags, f))
6973 return qe_invalid;
6974 32256 }
6975 else
6976 {
6977 72994 tempitem.moveflags = (move_obeys_grav | move_can_pitfall);
6978
2/2
✓ Branch 0 taken 70906 times.
✓ Branch 1 taken 2088 times.
72994 switch(tempitem.family)
6979 {
6980 case itype_bomb:
6981 case itype_sbomb:
6982 case itype_bait:
6983 case itype_liftglove:
6984 case itype_candle:
6985 case itype_book:
6986 2088 tempitem.wmoveflags = (move_obeys_grav | move_can_pitfall);
6987 2088 break;
6988 default:
6989 70906 tempitem.wmoveflags = move_none;
6990 70906 break;
6991 }
6992 }
6993
6994
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105250 times.
105250 if (!should_skip)
6995 {
6996
1/2
✓ Branch 0 taken 105250 times.
✗ Branch 1 not taken.
105250 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
6997 {
6998 tempitem.script = 0;
6999 tempitem.weaponscript = 0;
7000 for(int q = 0; q < 8; ++q)
7001 {
7002 tempitem.initiald[q] = 0;
7003 tempitem.weap_initiald[q] = 0;
7004 }
7005 }
7006 105250 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
7007 105250 }
7008 105250 }
7009
7010
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 477 times.
478 if (should_skip)
7011 1 return 0;
7012
7013 //////////////////////////////////////////////////////
7014 // Now do any updates because of new item additions
7015 // (These can't be done above because items_to_read
7016 // might be too low.)
7017 //////////////////////////////////////////////////////
7018
2/2
✓ Branch 0 taken 122112 times.
✓ Branch 1 taken 477 times.
122589 for(int32_t i=0; i<MAXITEMS; i++)
7019 {
7020 122112 memcpy(&tempitem, &itemsbuf[i], sizeof(itemdata));
7021
7022 //Account for older quests that didn't have an actual item for the used letter
7023
4/4
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 101120 times.
✓ Branch 2 taken 20910 times.
✓ Branch 3 taken 82 times.
122112 if(s_version < 2 && i==iLetterUsed)
7024 {
7025 82 reset_itembuf(&tempitem, iLetterUsed);
7026 82 strcpy(item_string[i],old_item_string[i]);
7027 82 tempitem.tile = itemsbuf[iLetter].tile;
7028 82 tempitem.csets = itemsbuf[iLetter].csets;
7029 82 tempitem.misc_flags = itemsbuf[iLetter].misc_flags;
7030 82 tempitem.frames = itemsbuf[iLetter].frames;
7031 82 tempitem.speed = itemsbuf[iLetter].speed;
7032 82 tempitem.ltm = itemsbuf[iLetter].ltm;
7033 82 }
7034
7035
2/2
✓ Branch 0 taken 101120 times.
✓ Branch 1 taken 20992 times.
122112 if(s_version < 3)
7036 {
7037
3/3
✓ Branch 0 taken 1804 times.
✓ Branch 1 taken 19106 times.
✓ Branch 2 taken 82 times.
20992 switch(i)
7038 {
7039 case iRocsFeather:
7040 case iHoverBoots:
7041 case iSpinScroll:
7042 case iL2SpinScroll:
7043 case iCrossScroll:
7044 case iQuakeScroll:
7045 case iL2QuakeScroll:
7046 case iWhispRing:
7047 case iL2WhispRing:
7048 case iChargeRing:
7049 case iL2ChargeRing:
7050 case iPerilScroll:
7051 case iWalletL3:
7052 case iQuiverL4:
7053 case iBombBagL4:
7054 case iBracelet:
7055 case iL2Bracelet:
7056 case iOldGlove:
7057 case iL2Ladder:
7058 case iWealthMedal:
7059 case iL2WealthMedal:
7060 case iL3WealthMedal:
7061 1804 reset_itembuf(&tempitem, i);
7062 1804 strcpy(item_string[i],old_item_string[i]);
7063 1804 break;
7064
7065 case iSShield:
7066 82 reset_itembuf(&tempitem, i);
7067 82 strcpy(item_string[i],old_item_string[i]);
7068 82 strcpy(item_string[iShield],old_item_string[iShield]);
7069 82 strcpy(item_string[iMShield],old_item_string[iMShield]);
7070 82 break;
7071 }
7072 20992 }
7073
7074
2/2
✓ Branch 0 taken 101120 times.
✓ Branch 1 taken 20992 times.
122112 if(s_version < 5)
7075 {
7076
2/2
✓ Branch 0 taken 574 times.
✓ Branch 1 taken 20418 times.
20992 switch(i)
7077 {
7078 case iHeartRing:
7079 case iL2HeartRing:
7080 case iL3HeartRing:
7081 case iMagicRing:
7082 case iL2MagicRing:
7083 case iL3MagicRing:
7084 case iL4MagicRing:
7085 574 reset_itembuf(&tempitem, i);
7086 574 strcpy(item_string[i],old_item_string[i]);
7087 574 break;
7088 }
7089 20992 }
7090
7091
2/2
✓ Branch 0 taken 101120 times.
✓ Branch 1 taken 20992 times.
122112 if(s_version < 6) // April 2007: Advanced item editing capabilities.
7092 {
7093
4/4
✓ Branch 0 taken 20910 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 20828 times.
20992 if(i!=iBPotion && i!=iRPotion)
7094
2/2
✓ Branch 0 taken 19304 times.
✓ Branch 1 taken 1524 times.
20828 if (get_bit(deprecated_rules,32)) tempitem.flags |= item_keep_old;
7095
7096
43/43
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 82 times.
✓ Branch 5 taken 82 times.
✓ Branch 6 taken 82 times.
✓ Branch 7 taken 82 times.
✓ Branch 8 taken 82 times.
✓ Branch 9 taken 82 times.
✓ Branch 10 taken 82 times.
✓ Branch 11 taken 82 times.
✓ Branch 12 taken 82 times.
✓ Branch 13 taken 82 times.
✓ Branch 14 taken 82 times.
✓ Branch 15 taken 82 times.
✓ Branch 16 taken 82 times.
✓ Branch 17 taken 82 times.
✓ Branch 18 taken 82 times.
✓ Branch 19 taken 82 times.
✓ Branch 20 taken 82 times.
✓ Branch 21 taken 82 times.
✓ Branch 22 taken 82 times.
✓ Branch 23 taken 82 times.
✓ Branch 24 taken 82 times.
✓ Branch 25 taken 82 times.
✓ Branch 26 taken 82 times.
✓ Branch 27 taken 82 times.
✓ Branch 28 taken 82 times.
✓ Branch 29 taken 82 times.
✓ Branch 30 taken 82 times.
✓ Branch 31 taken 82 times.
✓ Branch 32 taken 82 times.
✓ Branch 33 taken 328 times.
✓ Branch 34 taken 17302 times.
✓ Branch 35 taken 82 times.
✓ Branch 36 taken 82 times.
✓ Branch 37 taken 82 times.
✓ Branch 38 taken 82 times.
✓ Branch 39 taken 82 times.
✓ Branch 40 taken 82 times.
✓ Branch 41 taken 82 times.
✓ Branch 42 taken 82 times.
20992 switch(i)
7097 {
7098 case iTriforce:
7099 82 tempitem.fam_type=1;
7100 82 break;
7101
7102 case iBigTri:
7103 82 tempitem.fam_type=0;
7104 82 break;
7105
7106 case iBombs:
7107 82 tempitem.fam_type=i_bomb;
7108 82 tempitem.power=4;
7109 82 tempitem.wpn=wBOMB;
7110 82 tempitem.wpn2=wBOOM;
7111 82 tempitem.misc1 = 50;
7112
7113
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if(get_bit(deprecated_rules,qr_SLOWBOMBFUSES_DEP)) tempitem.misc1 = 200;
7114
7115 82 break;
7116
7117 case iSBomb:
7118 82 tempitem.fam_type=i_sbomb;
7119 82 tempitem.power=16;
7120 82 tempitem.wpn=wSBOMB;
7121 82 tempitem.wpn2=wSBOOM;
7122 82 tempitem.misc1 = 50;
7123
7124
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if(get_bit(deprecated_rules,qr_SLOWBOMBFUSES_DEP)) tempitem.misc1 = 400;
7125
7126 82 break;
7127
7128 case iBook:
7129
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if(get_bit(deprecated_rules, qr_FIREMAGICSPRITE_DEP))
7130 tempitem.wpn = wFIREMAGIC;
7131
7132 82 break;
7133
7134 case iSArrow:
7135 82 tempitem.wpn2 = get_bit(deprecated_rules,27) ? wSSPARKLE : 0; //qr_SASPARKLES
7136 82 tempitem.power=4;
7137 82 tempitem.flags|=item_gamedata;
7138 82 tempitem.wpn=wSARROW;
7139 82 break;
7140
7141 case iGArrow:
7142 82 tempitem.wpn2 = get_bit(deprecated_rules,28) ? wGSPARKLE : 0; //qr_GASPARKLES
7143 82 tempitem.power=8;
7144 82 tempitem.flags|=(item_gamedata|item_flag1);
7145 82 tempitem.wpn=wGARROW;
7146 82 break;
7147
7148 case iBrang:
7149 82 tempitem.power=0;
7150 82 tempitem.wpn=wBRANG;
7151 82 tempitem.misc1=36;
7152 82 break;
7153
7154 case iMBrang:
7155 82 tempitem.wpn2 = get_bit(deprecated_rules,29) ? wMSPARKLE : 0; //qr_MBSPARKLES
7156 82 tempitem.power=0;
7157 82 tempitem.wpn=wMBRANG;
7158 82 break;
7159
7160 case iFBrang:
7161 82 tempitem.wpn3 = get_bit(deprecated_rules,30) ? wFSPARKLE : 0; //qr_FBSPARKLES
7162 82 tempitem.power=2;
7163 82 tempitem.wpn=wFBRANG;
7164 82 break;
7165
7166 case iBoots:
7167 82 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICBOOTS_DEP) ? 1 : 0;
7168 82 tempitem.power=7;
7169 82 break;
7170
7171 case iWand:
7172 82 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICWAND_DEP) ? 8 : 0;
7173 82 tempitem.power=2;
7174 82 tempitem.wpn=wWAND;
7175 82 tempitem.wpn3=wMAGIC;
7176 82 break;
7177
7178 case iBCandle:
7179 82 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICCANDLE_DEP) ? 4 : 0;
7180 82 tempitem.power=1;
7181 82 tempitem.flags|=(item_gamedata|item_flag1);
7182 82 tempitem.wpn3=wFIRE;
7183 82 break;
7184
7185 case iRCandle:
7186 82 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICCANDLE_DEP) ? 4 : 0;
7187 82 tempitem.power=1;
7188 82 tempitem.wpn3=wFIRE;
7189 82 break;
7190
7191 case iSword:
7192 82 tempitem.power=1;
7193 82 tempitem.flags|= item_flag4 |item_flag2;
7194 82 tempitem.wpn=tempitem.wpn3=wSWORD;
7195 82 tempitem.wpn2=wSWORDSLASH;
7196 82 break;
7197
7198 case iWSword:
7199 82 tempitem.power=2;
7200 82 tempitem.flags|= item_flag4 |item_flag2;
7201 82 tempitem.wpn=tempitem.wpn3=wWSWORD;
7202 82 tempitem.wpn2=wWSWORDSLASH;
7203 82 break;
7204
7205 case iMSword:
7206 82 tempitem.power=4;
7207 82 tempitem.flags|= item_flag4 |item_flag2;
7208 82 tempitem.wpn=tempitem.wpn3=wMSWORD;
7209 82 tempitem.wpn2=wMSWORDSLASH;
7210 82 break;
7211
7212 case iXSword:
7213 82 tempitem.power=8;
7214 82 tempitem.flags|= item_flag4 |item_flag2;
7215 82 tempitem.wpn=tempitem.wpn3=wXSWORD;
7216 82 tempitem.wpn2=wXSWORDSLASH;
7217 82 break;
7218
7219 case iDivineProtection:
7220 82 tempitem.flags |= get_bit(deprecated_rules,qr_FLICKERINGDIVINEPROTECTIONROCKET_DEP) ? item_flag1 : item_none;
7221 82 tempitem.flags |= get_bit(deprecated_rules,qr_TRANSLUCENTDIVINEPROTECTIONROCKET_DEP) ? item_flag2 : item_none;
7222 82 tempitem.wpn=wDIVINEPROTECTION1A;
7223 82 tempitem.wpn2=wDIVINEPROTECTION1B;
7224 82 tempitem.wpn3=wDIVINEPROTECTIONS1A;
7225 82 tempitem.wpn4=wDIVINEPROTECTIONS1B;
7226 82 tempitem.wpn6=wDIVINEPROTECTION2A;
7227 82 tempitem.wpn7=wDIVINEPROTECTION2B;
7228 82 tempitem.wpn8=wDIVINEPROTECTIONS2A;
7229 82 tempitem.wpn9=wDIVINEPROTECTIONS2B;
7230 82 tempitem.wpn5 = iwDivineProtectionShieldFront;
7231 82 tempitem.wpn10 = iwDivineProtectionShieldBack;
7232 82 tempitem.misc1=512;
7233 82 tempitem.cost_amount[0]=64;
7234 82 break;
7235
7236 case iLens:
7237 82 tempitem.misc1=60;
7238 82 tempitem.flags |= get_qr(qr_ENABLEMAGIC) ? item_none : item_rupee_magic;
7239 82 tempitem.cost_amount[0] = get_qr(qr_ENABLEMAGIC) ? 2 : 1;
7240 82 break;
7241
7242 case iArrow:
7243 82 tempitem.power=2;
7244 82 tempitem.wpn=wARROW;
7245 82 break;
7246
7247 case iHoverBoots:
7248 82 tempitem.misc1=45;
7249 82 tempitem.wpn=iwHover;
7250 82 break;
7251
7252 case iDivineFire:
7253 82 tempitem.power=8;
7254 82 tempitem.wpn=wDIVINEFIRE1A;
7255 82 tempitem.wpn2=wDIVINEFIRE1B;
7256 82 tempitem.wpn3=wDIVINEFIRES1A;
7257 82 tempitem.wpn4=wDIVINEFIRES1B;
7258 82 tempitem.misc1 = 32;
7259 82 tempitem.misc2 = 200;
7260 82 tempitem.cost_amount[0]=32;
7261 82 break;
7262
7263 case iDivineEscape:
7264 82 tempitem.cost_amount[0]=32;
7265 82 break;
7266
7267 case iHookshot:
7268 82 tempitem.power=0;
7269 82 tempitem.flags&=~item_flag1;
7270 82 tempitem.wpn=wHSHEAD;
7271 82 tempitem.wpn2=wHSCHAIN_H;
7272 82 tempitem.wpn4=wHSHANDLE;
7273 82 tempitem.wpn3=wHSCHAIN_V;
7274 82 tempitem.misc1=50;
7275 82 tempitem.misc2=100;
7276 82 break;
7277
7278 case iLongshot:
7279 82 tempitem.power=0;
7280 82 tempitem.flags&=~item_flag1;
7281 82 tempitem.wpn=wLSHEAD;
7282 82 tempitem.wpn2=wLSCHAIN_H;
7283 82 tempitem.wpn4=wLSHANDLE;
7284 82 tempitem.wpn3=wLSCHAIN_V;
7285 82 tempitem.misc1=99;
7286 82 tempitem.misc2=100;
7287 82 break;
7288
7289 case iHammer:
7290 82 tempitem.power=4;
7291 82 tempitem.wpn=wHAMMER;
7292 82 tempitem.wpn2=iwHammerSmack;
7293 82 break;
7294
7295 case iCByrna:
7296 82 tempitem.power=1;
7297 82 tempitem.wpn=wCBYRNA;
7298 82 tempitem.wpn2=wCBYRNASLASH;
7299 82 tempitem.wpn3=wCBYRNAORB;
7300 82 tempitem.misc1=4;
7301 82 tempitem.misc2=16;
7302 82 tempitem.misc3=1;
7303 82 tempitem.cost_amount[0]=1;
7304 82 break;
7305
7306 case iWhistle:
7307 82 tempitem.wpn=wWIND;
7308 82 tempitem.misc1=3;
7309 82 tempitem.flags|=item_flag1;
7310 82 break;
7311
7312 case iBRing:
7313 82 tempitem.power=2;
7314 82 tempitem.misc1=spBLUE;
7315 82 break;
7316
7317 case iRRing:
7318 82 tempitem.power=4;
7319 82 tempitem.misc1=spRED;
7320 82 break;
7321
7322 case iGRing:
7323 82 tempitem.power=8;
7324 82 tempitem.misc1=spGOLD;
7325 82 break;
7326
7327 case iSpinScroll:
7328 82 tempitem.power = 2;
7329 82 tempitem.misc1 = 1;
7330 82 break;
7331
7332 case iL2SpinScroll:
7333 82 tempitem.family=itype_spinscroll2;
7334 82 tempitem.fam_type=1;
7335 82 tempitem.cost_amount[0]=8;
7336 82 tempitem.power=2;
7337 82 tempitem.misc1 = 20;
7338 82 break;
7339
7340 case iQuakeScroll:
7341 82 tempitem.misc1=0x10;
7342 82 tempitem.misc2=64;
7343 82 break;
7344
7345 case iL2QuakeScroll:
7346 82 tempitem.family=itype_quakescroll2;
7347 82 tempitem.fam_type=1;
7348 82 tempitem.power = 2;
7349 82 tempitem.misc1=0x20;
7350 82 tempitem.misc2=192;
7351 82 tempitem.cost_amount[0]=8;
7352 82 break;
7353
7354 case iChargeRing:
7355 82 tempitem.misc1=64;
7356 82 tempitem.misc2=128;
7357 82 break;
7358
7359 case iL2ChargeRing:
7360 82 tempitem.misc1=32;
7361 82 tempitem.misc2=64;
7362 82 break;
7363
7364 case iOldGlove:
7365 82 tempitem.flags |= item_flag1;
7366
7367 //fallthrough
7368 case iBombBagL4:
7369 case iWalletL3:
7370 case iQuiverL4:
7371 case iBracelet:
7372 410 tempitem.power = 1;
7373 410 break;
7374
7375 case iL2Bracelet:
7376 82 tempitem.power = 2;
7377 82 break;
7378
7379 case iMKey:
7380 82 tempitem.power=0xFF;
7381 82 tempitem.flags |= item_flag1;
7382 82 break;
7383 }
7384 20992 }
7385
7386
2/2
✓ Branch 0 taken 101120 times.
✓ Branch 1 taken 20992 times.
122112 if(s_version < 7)
7387 {
7388
2/2
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 20664 times.
20992 switch(i)
7389 {
7390 case iStoneAgony:
7391 case iStompBoots:
7392 case iPerilRing:
7393 case iWhimsicalRing:
7394 {
7395 328 reset_itembuf(&tempitem, i);
7396 328 strcpy(item_string[i],old_item_string[i]);
7397 328 break;
7398 }
7399 }
7400 20992 }
7401
7402
2/2
✓ Branch 0 taken 101120 times.
✓ Branch 1 taken 20992 times.
122112 if(s_version < 8) // May 2007: Some corrections.
7403 {
7404
7/7
✓ Branch 0 taken 246 times.
✓ Branch 1 taken 20336 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 82 times.
✓ Branch 5 taken 82 times.
✓ Branch 6 taken 82 times.
20992 switch(i)
7405 {
7406 case iMShield:
7407 82 tempitem.misc1|=sh_flame;
7408 82 tempitem.misc2|=sh_fireball|sh_magic;
7409
7410
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if(get_qr(qr_SWORDMIRROR))
7411 {
7412 tempitem.misc2 |= sh_sword;
7413 }
7414
7415 // fallthrough
7416 case iShield:
7417 164 tempitem.misc1|=sh_fireball|sh_sword|sh_magic;
7418
7419 // fallthrough
7420 case iSShield:
7421 246 tempitem.misc1|=sh_rock|sh_arrow|sh_brang|sh_script;
7422
7423
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 246 times.
246 if(get_bit(deprecated_rules,102)) //qr_REFLECTROCKS
7424 {
7425 tempitem.misc2 |= sh_rock;
7426 }
7427
7428 246 break;
7429
7430 case iWhispRing:
7431 82 tempitem.power=1;
7432 82 tempitem.flags|=item_gamedata|item_flag1;
7433 82 tempitem.misc1 = 3;
7434 82 break;
7435
7436 case iL2WhispRing:
7437 82 tempitem.power=0;
7438 82 tempitem.flags|=item_gamedata|item_flag1;
7439 82 tempitem.misc1 = 3;
7440 82 break;
7441
7442 case iL2Ladder:
7443 case iBow:
7444 case iCByrna:
7445 246 tempitem.power = 1;
7446 246 break;
7447 }
7448 20992 }
7449
7450
4/4
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 101120 times.
✓ Branch 2 taken 20910 times.
✓ Branch 3 taken 82 times.
122112 if(s_version < 9 && i==iClock)
7451 {
7452 82 tempitem.misc1 = get_bit(deprecated_rules, qr_TEMPCLOCKS_DEP) ? 256 : 0;
7453 82 }
7454
7455 //add the misc flag for bomb
7456
4/4
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 101120 times.
✓ Branch 2 taken 20910 times.
✓ Branch 3 taken 82 times.
122112 if(s_version < 10 && tempitem.family == itype_bomb)
7457 {
7458 82 tempitem.flags = (tempitem.flags & ~item_flag1) | (get_qr(qr_LONGBOMBBOOM_DEP) ? item_flag1 : item_none);
7459 82 }
7460
7461
4/4
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 101120 times.
✓ Branch 2 taken 20828 times.
✓ Branch 3 taken 164 times.
122112 if(s_version < 11 && tempitem.family == itype_triforcepiece)
7462 {
7463 164 tempitem.flags = (tempitem.fam_type ? item_gamedata : item_none);
7464 164 tempitem.playsound = (tempitem.fam_type ? WAV_SCALE : WAV_CLEARED);
7465 164 }
7466
7467
2/2
✓ Branch 0 taken 101120 times.
✓ Branch 1 taken 20992 times.
122112 if(s_version < 12) // June 2007: More Misc. attributes.
7468 {
7469
5/5
✓ Branch 0 taken 164 times.
✓ Branch 1 taken 20582 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 82 times.
20992 switch(i)
7470 {
7471 case iFBrang:
7472 82 tempitem.misc4 |= sh_fireball|sh_sword|sh_magic;
7473
7474 //fallthrough
7475 case iMBrang:
7476 164 tempitem.misc3 |= sh_sword|sh_magic;
7477
7478 //fallthrough
7479 case iHookshot:
7480 case iLongshot:
7481 //fallthrough
7482 328 tempitem.misc3 |= sh_fireball;
7483
7484 case iBrang:
7485 410 tempitem.misc3 |= sh_brang|sh_rock|sh_arrow;
7486 410 break;
7487 }
7488
7489
16/16
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 246 times.
✓ Branch 4 taken 164 times.
✓ Branch 5 taken 246 times.
✓ Branch 6 taken 246 times.
✓ Branch 7 taken 9313 times.
✓ Branch 8 taken 82 times.
✓ Branch 9 taken 82 times.
✓ Branch 10 taken 82 times.
✓ Branch 11 taken 82 times.
✓ Branch 12 taken 82 times.
✓ Branch 13 taken 328 times.
✓ Branch 14 taken 164 times.
✓ Branch 15 taken 9629 times.
20992 switch(tempitem.family)
7490 {
7491 case itype_hoverboots:
7492 82 tempitem.usesound = WAV_ZN1HOVER;
7493 82 break;
7494
7495 case itype_wand:
7496 82 tempitem.usesound = WAV_WAND;
7497 82 break;
7498
7499 case itype_book:
7500 82 tempitem.usesound = WAV_FIRE;
7501 82 break;
7502
7503 case itype_arrow:
7504 246 tempitem.usesound = WAV_ARROW;
7505 246 break;
7506
7507 case itype_hookshot:
7508 164 tempitem.usesound = WAV_HOOKSHOT;
7509 164 break;
7510
7511 case itype_brang:
7512 246 tempitem.usesound = WAV_BRANG;
7513 246 break;
7514
7515 case itype_shield:
7516 246 tempitem.usesound = WAV_CHINK;
7517 246 break;
7518
7519 case itype_sword:
7520 9313 tempitem.usesound = WAV_SWORD;
7521 9313 break;
7522
7523 case itype_whistle:
7524 82 tempitem.usesound = WAV_WHISTLE;
7525 82 break;
7526
7527 case itype_hammer:
7528 82 tempitem.usesound = WAV_HAMMER;
7529 82 break;
7530
7531 case itype_divinefire:
7532 82 tempitem.usesound = WAV_ZN1DIVINEFIRE;
7533 82 break;
7534
7535 case itype_divineescape:
7536 82 tempitem.usesound = WAV_ZN1DIVINEESCAPE;
7537 82 break;
7538
7539 case itype_divineprotection:
7540 82 tempitem.usesound = WAV_ZN1DIVINEPROTECTION1;
7541 82 break;
7542
7543 case itype_bomb:
7544 case itype_sbomb:
7545 case itype_quakescroll:
7546 case itype_quakescroll2:
7547 328 tempitem.usesound = WAV_BOMB;
7548 328 break;
7549
7550 case itype_spinscroll:
7551 case itype_spinscroll2:
7552 164 tempitem.usesound = WAV_ZN1SPINATTACK;
7553 164 break;
7554 }
7555 20992 }
7556
7557
2/2
✓ Branch 0 taken 101120 times.
✓ Branch 1 taken 20992 times.
122112 if(s_version < 13) // July 2007
7558 {
7559
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 20910 times.
20992 if(tempitem.family == itype_whistle)
7560 {
7561 82 tempitem.misc1 = (tempitem.power==2 ? 4 : 3);
7562 82 tempitem.power = 1;
7563 82 tempitem.flags|=item_flag1;
7564 82 }
7565
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 20828 times.
20910 else if(tempitem.family == itype_wand)
7566 82 tempitem.flags|=item_flag1;
7567
2/2
✓ Branch 0 taken 20746 times.
✓ Branch 1 taken 82 times.
20828 else if(tempitem.family == itype_book)
7568 {
7569 82 tempitem.flags|=item_flag1;
7570 82 tempitem.power = 2;
7571 82 }
7572 20992 }
7573
7574
2/2
✓ Branch 0 taken 101120 times.
✓ Branch 1 taken 20992 times.
122112 if(s_version < 14) // August 2007
7575 {
7576
2/2
✓ Branch 0 taken 164 times.
✓ Branch 1 taken 20828 times.
20992 if(tempitem.family == itype_fairy)
7577 {
7578 164 tempitem.usesound = WAV_SCALE;
7579
7580
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 164 times.
164 if(tempitem.fam_type)
7581 164 tempitem.misc3=50;
7582 164 }
7583
2/2
✓ Branch 0 taken 20664 times.
✓ Branch 1 taken 164 times.
20828 else if(tempitem.family == itype_potion)
7584 {
7585 164 tempitem.flags |= item_gain_old;
7586 164 }
7587 20992 }
7588
7589
2/2
✓ Branch 0 taken 101120 times.
✓ Branch 1 taken 20992 times.
122112 if(s_version < 17) // November 2007
7590 {
7591
3/4
✓ Branch 0 taken 164 times.
✓ Branch 1 taken 20828 times.
✓ Branch 2 taken 164 times.
✗ Branch 3 not taken.
20992 if(tempitem.family == itype_candle && !tempitem.wpn3)
7592 {
7593 tempitem.wpn3 = wFIRE;
7594 }
7595
4/4
✓ Branch 0 taken 246 times.
✓ Branch 1 taken 20746 times.
✓ Branch 2 taken 164 times.
✓ Branch 3 taken 82 times.
20992 else if(tempitem.family == itype_arrow && tempitem.power>4)
7596 {
7597 82 tempitem.flags|=item_flag1;
7598 82 }
7599 20992 }
7600
7601
2/2
✓ Branch 0 taken 101120 times.
✓ Branch 1 taken 20992 times.
122112 if(s_version < 18) // New Year's Eve 2007
7602 {
7603
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 20910 times.
20992 if(tempitem.family == itype_whistle)
7604 82 tempitem.misc2 = 8; // Use the Whistle warp ring
7605
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 20828 times.
20910 else if(tempitem.family == itype_bait)
7606 82 tempitem.misc1 = 768; // Frames until it goes
7607
2/2
✓ Branch 0 taken 20664 times.
✓ Branch 1 taken 164 times.
20828 else if(tempitem.family == itype_triforcepiece)
7608 {
7609
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 82 times.
164 if(tempitem.flags & item_gamedata)
7610 {
7611 82 tempitem.misc2 = 1; // Cutscene 1
7612 82 tempitem.flags |= item_flag1; // Side Warp Out
7613 82 }
7614 164 }
7615 20992 }
7616
7617
2/2
✓ Branch 0 taken 101120 times.
✓ Branch 1 taken 20992 times.
122112 if(s_version < 19) // January 2008
7618 {
7619
2/2
✓ Branch 0 taken 20910 times.
✓ Branch 1 taken 82 times.
20992 if(tempitem.family == itype_divineprotection)
7620 {
7621
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 2 times.
82 if (get_bit(deprecated_rules,qr_NOBOMBPALFLASH+1)) tempitem.flags |= item_flag3;
7622
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 10 times.
82 if (get_bit(deprecated_rules,qr_NOBOMBPALFLASH+2)) tempitem.flags |= item_flag4;
7623 82 }
7624 20992 }
7625
7626
2/2
✓ Branch 0 taken 101120 times.
✓ Branch 1 taken 20992 times.
122112 if(s_version < 20) // October 2008
7627 {
7628
2/2
✓ Branch 0 taken 20910 times.
✓ Branch 1 taken 82 times.
20992 if(tempitem.family == itype_divineprotection)
7629 {
7630 82 tempitem.wpn6=wDIVINEPROTECTION2A;
7631 82 tempitem.wpn7=wDIVINEPROTECTION2B;
7632 82 tempitem.wpn8=wDIVINEPROTECTIONS2A;
7633 82 tempitem.wpn9=wDIVINEPROTECTIONS2B;
7634 82 tempitem.wpn5 = iwDivineProtectionShieldFront;
7635 82 tempitem.wpn10 = iwDivineProtectionShieldBack;
7636 82 }
7637 20992 }
7638
7639
2/2
✓ Branch 0 taken 101120 times.
✓ Branch 1 taken 20992 times.
122112 if(s_version < 21) // November 2008
7640 {
7641
1/2
✓ Branch 0 taken 20992 times.
✗ Branch 1 not taken.
20992 if(tempitem.flags & 0x0100) // item_slash
7642 {
7643 tempitem.flags &= ~item_unused;
7644
7645 if(tempitem.family == itype_sword ||
7646 tempitem.family == itype_wand ||
7647 tempitem.family == itype_candle ||
7648 tempitem.family == itype_cbyrna)
7649 {
7650 tempitem.flags |= item_flag4;
7651 }
7652 }
7653 20992 }
7654
7655
2/2
✓ Branch 0 taken 101120 times.
✓ Branch 1 taken 20992 times.
122112 if(s_version < 22) // September 2009
7656 {
7657
4/4
✓ Branch 0 taken 20910 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 20828 times.
20992 if(tempitem.family == itype_sbomb || tempitem.family == itype_bomb)
7658 {
7659 164 tempitem.misc3 = tempitem.power/2;
7660 164 }
7661 20992 }
7662
7663
2/2
✓ Branch 0 taken 101120 times.
✓ Branch 1 taken 20992 times.
122112 if(s_version < 23) // March 2011
7664 {
7665
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 20910 times.
20992 if(tempitem.family == itype_divinefire)
7666 82 tempitem.wpn5 = wFIRE;
7667
2/2
✓ Branch 0 taken 20828 times.
✓ Branch 1 taken 82 times.
20910 else if(tempitem.family == itype_book)
7668 82 tempitem.wpn2 = wFIRE;
7669 20992 }
7670
7671 // Version 25: Bomb bags were acting as though "super bombs also" was checked
7672 // whether it was or not, and a lot of existing quests depended on the
7673 // incorrect behavior.
7674
2/2
✓ Branch 0 taken 101120 times.
✓ Branch 1 taken 20992 times.
122112 if(s_version < 25) // January 2012
7675 {
7676
2/2
✓ Branch 0 taken 20664 times.
✓ Branch 1 taken 328 times.
20992 if(tempitem.family == itype_bombbag)
7677 328 tempitem.flags |= item_flag1;
7678
7679
2/2
✓ Branch 0 taken 20910 times.
✓ Branch 1 taken 82 times.
20992 if(tempitem.family == itype_divinefire)
7680 82 tempitem.flags |= item_flag3; // Sideview gravity flag
7681 20992 }
7682
7683
2/2
✓ Branch 0 taken 48640 times.
✓ Branch 1 taken 73472 times.
122112 if( version < 0x254) //Nuke greyed-out flags/values from <=2.53, in case they are used in 2.54/2.55
7684 {
7685
60/60
✓ Branch 0 taken 568 times.
✓ Branch 1 taken 568 times.
✓ Branch 2 taken 284 times.
✓ Branch 3 taken 568 times.
✓ Branch 4 taken 1136 times.
✓ Branch 5 taken 284 times.
✓ Branch 6 taken 284 times.
✓ Branch 7 taken 568 times.
✓ Branch 8 taken 311 times.
✓ Branch 9 taken 10996 times.
✓ Branch 10 taken 2923 times.
✓ Branch 11 taken 857 times.
✓ Branch 12 taken 3317 times.
✓ Branch 13 taken 11233 times.
✓ Branch 14 taken 17688 times.
✓ Branch 15 taken 859 times.
✓ Branch 16 taken 844 times.
✓ Branch 17 taken 610 times.
✓ Branch 18 taken 332 times.
✓ Branch 19 taken 287 times.
✓ Branch 20 taken 568 times.
✓ Branch 21 taken 623 times.
✓ Branch 22 taken 302 times.
✓ Branch 23 taken 932 times.
✓ Branch 24 taken 907 times.
✓ Branch 25 taken 565 times.
✓ Branch 26 taken 873 times.
✓ Branch 27 taken 284 times.
✓ Branch 28 taken 300 times.
✓ Branch 29 taken 284 times.
✓ Branch 30 taken 861 times.
✓ Branch 31 taken 287 times.
✓ Branch 32 taken 290 times.
✓ Branch 33 taken 570 times.
✓ Branch 34 taken 260 times.
✓ Branch 35 taken 287 times.
✓ Branch 36 taken 284 times.
✓ Branch 37 taken 284 times.
✓ Branch 38 taken 300 times.
✓ Branch 39 taken 286 times.
✓ Branch 40 taken 287 times.
✓ Branch 41 taken 284 times.
✓ Branch 42 taken 289 times.
✓ Branch 43 taken 785 times.
✓ Branch 44 taken 284 times.
✓ Branch 45 taken 555 times.
✓ Branch 46 taken 1136 times.
✓ Branch 47 taken 284 times.
✓ Branch 48 taken 284 times.
✓ Branch 49 taken 284 times.
✓ Branch 50 taken 571 times.
✓ Branch 51 taken 284 times.
✓ Branch 52 taken 855 times.
✓ Branch 53 taken 858 times.
✓ Branch 54 taken 1148 times.
✓ Branch 55 taken 284 times.
✓ Branch 56 taken 284 times.
✓ Branch 57 taken 284 times.
✓ Branch 58 taken 284 times.
✓ Branch 59 taken 284 times.
73472 switch(tempitem.family)
7686 {
7687 case itype_sword:
7688 {
7689 17688 tempitem.flags &= ~(item_flag5);
7690 17688 tempitem.misc3 = 0;
7691 17688 tempitem.misc4 = 0;
7692 17688 tempitem.misc5 = 0;
7693 17688 tempitem.misc6 = 0;
7694 17688 tempitem.misc7 = 0;
7695 17688 tempitem.misc8 = 0;
7696 17688 tempitem.misc9 = 0;
7697 17688 tempitem.misc10 = 0;
7698 17688 tempitem.wpn4 = 0;
7699 17688 tempitem.wpn5 = 0;
7700 17688 tempitem.wpn6 = 0;
7701 17688 tempitem.wpn7 = 0;
7702 17688 tempitem.wpn8 = 0;
7703 17688 tempitem.wpn9 = 0;
7704 17688 tempitem.wpn10 = 0;
7705 17688 break;
7706 }
7707 case itype_brang:
7708 {
7709 859 tempitem.flags &= ~(item_flag4 | item_flag5);
7710 859 tempitem.misc2 = 0;
7711 859 tempitem.misc5 = 0;
7712 859 tempitem.misc6 = 0;
7713 859 tempitem.misc7 = 0;
7714 859 tempitem.misc8 = 0;
7715 859 tempitem.misc9 = 0;
7716 859 tempitem.misc10 = 0;
7717 859 tempitem.wpn4 = 0;
7718 859 tempitem.wpn5 = 0;
7719 859 tempitem.wpn6 = 0;
7720 859 tempitem.wpn7 = 0;
7721 859 tempitem.wpn8 = 0;
7722 859 tempitem.wpn9 = 0;
7723 859 tempitem.wpn10 = 0;
7724 859 break;
7725 }
7726 case itype_arrow:
7727 {
7728 844 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
7729 844 tempitem.misc2 = 0;
7730 844 tempitem.misc3 = 0;
7731 844 tempitem.misc4 = 0;
7732 844 tempitem.misc5 = 0;
7733 844 tempitem.misc6 = 0;
7734 844 tempitem.misc7 = 0;
7735 844 tempitem.misc8 = 0;
7736 844 tempitem.misc9 = 0;
7737 844 tempitem.misc10 = 0;
7738 844 tempitem.wpn4 = 0;
7739 844 tempitem.wpn5 = 0;
7740 844 tempitem.wpn6 = 0;
7741 844 tempitem.wpn7 = 0;
7742 844 tempitem.wpn8 = 0;
7743 844 tempitem.wpn9 = 0;
7744 844 tempitem.wpn10 = 0;
7745 844 break;
7746 }
7747 case itype_candle:
7748 {
7749 610 tempitem.flags &= ~ (item_flag3 | item_flag5);
7750 610 tempitem.misc1 = 0;
7751 610 tempitem.misc2 = 0;
7752 610 tempitem.misc3 = 0;
7753 610 tempitem.misc4 = 0;
7754 610 tempitem.misc5 = 0;
7755 610 tempitem.misc6 = 0;
7756 610 tempitem.misc7 = 0;
7757 610 tempitem.misc8 = 0;
7758 610 tempitem.misc9 = 0;
7759 610 tempitem.misc10 = 0;
7760 610 tempitem.wpn4 = 0;
7761 610 tempitem.wpn5 = 0;
7762 610 tempitem.wpn6 = 0;
7763 610 tempitem.wpn7 = 0;
7764 610 tempitem.wpn8 = 0;
7765 610 tempitem.wpn9 = 0;
7766 610 tempitem.wpn10 = 0;
7767 610 break;
7768 }
7769 case itype_whistle:
7770 {
7771 332 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
7772 332 tempitem.misc3 = 0;
7773 332 tempitem.misc4 = 0;
7774 332 tempitem.misc5 = 0;
7775 332 tempitem.misc6 = 0;
7776 332 tempitem.misc7 = 0;
7777 332 tempitem.misc8 = 0;
7778 332 tempitem.misc9 = 0;
7779 332 tempitem.misc10 = 0;
7780 332 tempitem.wpn2 = 0;
7781 332 tempitem.wpn3 = 0;
7782 332 tempitem.wpn4 = 0;
7783 332 tempitem.wpn5 = 0;
7784 332 tempitem.wpn6 = 0;
7785 332 tempitem.wpn7 = 0;
7786 332 tempitem.wpn8 = 0;
7787 332 tempitem.wpn9 = 0;
7788 332 tempitem.wpn10 = 0;
7789 332 break;
7790 }
7791 case itype_bait:
7792 {
7793 287 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
7794 287 tempitem.misc2 = 0;
7795 287 tempitem.misc3 = 0;
7796 287 tempitem.misc4 = 0;
7797 287 tempitem.misc5 = 0;
7798 287 tempitem.misc6 = 0;
7799 287 tempitem.misc7 = 0;
7800 287 tempitem.misc8 = 0;
7801 287 tempitem.misc9 = 0;
7802 287 tempitem.misc10 = 0;
7803 287 tempitem.wpn2 = 0;
7804 287 tempitem.wpn3 = 0;
7805 287 tempitem.wpn4 = 0;
7806 287 tempitem.wpn5 = 0;
7807 287 tempitem.wpn6 = 0;
7808 287 tempitem.wpn7 = 0;
7809 287 tempitem.wpn8 = 0;
7810 287 tempitem.wpn9 = 0;
7811 287 tempitem.wpn10 = 0;
7812 287 break;
7813 }
7814 case itype_letter:
7815 {
7816 568 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
7817 568 tempitem.misc1 = 0;
7818 568 tempitem.misc2 = 0;
7819 568 tempitem.misc3 = 0;
7820 568 tempitem.misc4 = 0;
7821 568 tempitem.misc5 = 0;
7822 568 tempitem.misc6 = 0;
7823 568 tempitem.misc7 = 0;
7824 568 tempitem.misc8 = 0;
7825 568 tempitem.misc9 = 0;
7826 568 tempitem.misc10 = 0;
7827 568 tempitem.wpn = 0;
7828 568 tempitem.wpn2 = 0;
7829 568 tempitem.wpn3 = 0;
7830 568 tempitem.wpn4 = 0;
7831 568 tempitem.wpn5 = 0;
7832 568 tempitem.wpn6 = 0;
7833 568 tempitem.wpn7 = 0;
7834 568 tempitem.wpn8 = 0;
7835 568 tempitem.wpn9 = 0;
7836 568 tempitem.wpn10 = 0;
7837 568 break;
7838 }
7839 case itype_potion:
7840 {
7841 623 tempitem.flags &= ~ (item_flag3 | item_flag4 | item_flag5);
7842 623 tempitem.misc3 = 0;
7843 623 tempitem.misc4 = 0;
7844 623 tempitem.misc5 = 0;
7845 623 tempitem.misc6 = 0;
7846 623 tempitem.misc7 = 0;
7847 623 tempitem.misc8 = 0;
7848 623 tempitem.misc9 = 0;
7849 623 tempitem.misc10 = 0;
7850 623 tempitem.wpn = 0;
7851 623 tempitem.wpn2 = 0;
7852 623 tempitem.wpn3 = 0;
7853 623 tempitem.wpn4 = 0;
7854 623 tempitem.wpn5 = 0;
7855 623 tempitem.wpn6 = 0;
7856 623 tempitem.wpn7 = 0;
7857 623 tempitem.wpn8 = 0;
7858 623 tempitem.wpn9 = 0;
7859 623 tempitem.wpn10 = 0;
7860 623 break;
7861 }
7862 case itype_wand:
7863 {
7864 302 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag5);
7865 302 tempitem.misc1 = 0;
7866 302 tempitem.misc2 = 0;
7867 302 tempitem.misc3 = 0;
7868 302 tempitem.misc4 = 0;
7869 302 tempitem.misc5 = 0;
7870 302 tempitem.misc6 = 0;
7871 302 tempitem.misc7 = 0;
7872 302 tempitem.misc8 = 0;
7873 302 tempitem.misc9 = 0;
7874 302 tempitem.misc10 = 0;
7875 302 tempitem.wpn4 = 0;
7876 302 tempitem.wpn5 = 0;
7877 302 tempitem.wpn6 = 0;
7878 302 tempitem.wpn7 = 0;
7879 302 tempitem.wpn8 = 0;
7880 302 tempitem.wpn9 = 0;
7881 302 tempitem.wpn10 = 0;
7882 302 break;
7883 }
7884 case itype_ring:
7885 {
7886 932 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
7887 932 tempitem.misc2 = 0;
7888 932 tempitem.misc3 = 0;
7889 932 tempitem.misc4 = 0;
7890 932 tempitem.misc5 = 0;
7891 932 tempitem.misc6 = 0;
7892 932 tempitem.misc7 = 0;
7893 932 tempitem.misc8 = 0;
7894 932 tempitem.misc9 = 0;
7895 932 tempitem.misc10 = 0;
7896 932 tempitem.wpn = 0;
7897 932 tempitem.wpn2 = 0;
7898 932 tempitem.wpn3 = 0;
7899 932 tempitem.wpn4 = 0;
7900 932 tempitem.wpn5 = 0;
7901 932 tempitem.wpn6 = 0;
7902 932 tempitem.wpn7 = 0;
7903 932 tempitem.wpn8 = 0;
7904 932 tempitem.wpn9 = 0;
7905 932 tempitem.wpn10 = 0;
7906 932 break;
7907 }
7908 case itype_wallet:
7909 {
7910 907 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
7911 907 tempitem.misc3 = 0;
7912 907 tempitem.misc4 = 0;
7913 907 tempitem.misc5 = 0;
7914 907 tempitem.misc6 = 0;
7915 907 tempitem.misc7 = 0;
7916 907 tempitem.misc8 = 0;
7917 907 tempitem.misc9 = 0;
7918 907 tempitem.misc10 = 0;
7919 907 tempitem.wpn = 0;
7920 907 tempitem.wpn2 = 0;
7921 907 tempitem.wpn3 = 0;
7922 907 tempitem.wpn4 = 0;
7923 907 tempitem.wpn5 = 0;
7924 907 tempitem.wpn6 = 0;
7925 907 tempitem.wpn7 = 0;
7926 907 tempitem.wpn8 = 0;
7927 907 tempitem.wpn9 = 0;
7928 907 tempitem.wpn10 = 0;
7929 907 break;
7930 }
7931 case itype_amulet:
7932 {
7933 565 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
7934 565 tempitem.misc1 = 0;
7935 565 tempitem.misc2 = 0;
7936 565 tempitem.misc3 = 0;
7937 565 tempitem.misc4 = 0;
7938 565 tempitem.misc5 = 0;
7939 565 tempitem.misc6 = 0;
7940 565 tempitem.misc7 = 0;
7941 565 tempitem.misc8 = 0;
7942 565 tempitem.misc9 = 0;
7943 565 tempitem.misc10 = 0;
7944 565 tempitem.wpn = 0;
7945 565 tempitem.wpn2 = 0;
7946 565 tempitem.wpn3 = 0;
7947 565 tempitem.wpn4 = 0;
7948 565 tempitem.wpn5 = 0;
7949 565 tempitem.wpn6 = 0;
7950 565 tempitem.wpn7 = 0;
7951 565 tempitem.wpn8 = 0;
7952 565 tempitem.wpn9 = 0;
7953 565 tempitem.wpn10 = 0;
7954 565 break;
7955 }
7956 case itype_shield:
7957 {
7958 873 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
7959 873 tempitem.misc3 = 0;
7960 873 tempitem.misc4 = 0;
7961 873 tempitem.misc5 = 0;
7962 873 tempitem.misc6 = 0;
7963 873 tempitem.misc7 = 0;
7964 873 tempitem.misc8 = 0;
7965 873 tempitem.misc9 = 0;
7966 873 tempitem.misc10 = 0;
7967 873 tempitem.wpn = 0;
7968 873 tempitem.wpn2 = 0;
7969 873 tempitem.wpn3 = 0;
7970 873 tempitem.wpn4 = 0;
7971 873 tempitem.wpn5 = 0;
7972 873 tempitem.wpn6 = 0;
7973 873 tempitem.wpn7 = 0;
7974 873 tempitem.wpn8 = 0;
7975 873 tempitem.wpn9 = 0;
7976 873 tempitem.wpn10 = 0;
7977 873 break;
7978 }
7979 case itype_bow:
7980 {
7981 568 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
7982 568 tempitem.misc1 = 0;
7983 568 tempitem.misc2 = 0;
7984 568 tempitem.misc3 = 0;
7985 568 tempitem.misc4 = 0;
7986 568 tempitem.misc5 = 0;
7987 568 tempitem.misc6 = 0;
7988 568 tempitem.misc7 = 0;
7989 568 tempitem.misc8 = 0;
7990 568 tempitem.misc9 = 0;
7991 568 tempitem.misc10 = 0;
7992 568 tempitem.wpn = 0;
7993 568 tempitem.wpn2 = 0;
7994 568 tempitem.wpn3 = 0;
7995 568 tempitem.wpn4 = 0;
7996 568 tempitem.wpn5 = 0;
7997 568 tempitem.wpn6 = 0;
7998 568 tempitem.wpn7 = 0;
7999 568 tempitem.wpn8 = 0;
8000 568 tempitem.wpn9 = 0;
8001 568 tempitem.wpn10 = 0;
8002 568 break;
8003 }
8004 case itype_raft:
8005 {
8006 284 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8007 284 tempitem.misc1 = 0;
8008 284 tempitem.misc2 = 0;
8009 284 tempitem.misc3 = 0;
8010 284 tempitem.misc4 = 0;
8011 284 tempitem.misc5 = 0;
8012 284 tempitem.misc6 = 0;
8013 284 tempitem.misc7 = 0;
8014 284 tempitem.misc8 = 0;
8015 284 tempitem.misc9 = 0;
8016 284 tempitem.misc10 = 0;
8017 284 tempitem.wpn = 0;
8018 284 tempitem.wpn2 = 0;
8019 284 tempitem.wpn3 = 0;
8020 284 tempitem.wpn4 = 0;
8021 284 tempitem.wpn5 = 0;
8022 284 tempitem.wpn6 = 0;
8023 284 tempitem.wpn7 = 0;
8024 284 tempitem.wpn8 = 0;
8025 284 tempitem.wpn9 = 0;
8026 284 tempitem.wpn10 = 0;
8027 284 break;
8028 }
8029 case itype_ladder:
8030 {
8031 568 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8032 568 tempitem.misc1 = 0;
8033 568 tempitem.misc2 = 0;
8034 568 tempitem.misc3 = 0;
8035 568 tempitem.misc4 = 0;
8036 568 tempitem.misc5 = 0;
8037 568 tempitem.misc6 = 0;
8038 568 tempitem.misc7 = 0;
8039 568 tempitem.misc8 = 0;
8040 568 tempitem.misc9 = 0;
8041 568 tempitem.misc10 = 0;
8042 568 tempitem.wpn = 0;
8043 568 tempitem.wpn2 = 0;
8044 568 tempitem.wpn3 = 0;
8045 568 tempitem.wpn4 = 0;
8046 568 tempitem.wpn5 = 0;
8047 568 tempitem.wpn6 = 0;
8048 568 tempitem.wpn7 = 0;
8049 568 tempitem.wpn8 = 0;
8050 568 tempitem.wpn9 = 0;
8051 568 tempitem.wpn10 = 0;
8052 568 break;
8053 }
8054 case itype_book:
8055 {
8056 300 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8057 300 tempitem.misc1 = 0;
8058 300 tempitem.misc2 = 0;
8059 300 tempitem.misc3 = 0;
8060 300 tempitem.misc4 = 0;
8061 300 tempitem.misc5 = 0;
8062 300 tempitem.misc6 = 0;
8063 300 tempitem.misc7 = 0;
8064 300 tempitem.misc8 = 0;
8065 300 tempitem.misc9 = 0;
8066 300 tempitem.misc10 = 0;
8067 300 tempitem.wpn3 = 0;
8068 300 tempitem.wpn4 = 0;
8069 300 tempitem.wpn5 = 0;
8070 300 tempitem.wpn6 = 0;
8071 300 tempitem.wpn7 = 0;
8072 300 tempitem.wpn8 = 0;
8073 300 tempitem.wpn9 = 0;
8074 300 tempitem.wpn10 = 0;
8075 300 break;
8076 }
8077 case itype_magickey:
8078 {
8079 284 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8080 284 tempitem.misc1 = 0;
8081 284 tempitem.misc2 = 0;
8082 284 tempitem.misc3 = 0;
8083 284 tempitem.misc4 = 0;
8084 284 tempitem.misc5 = 0;
8085 284 tempitem.misc6 = 0;
8086 284 tempitem.misc7 = 0;
8087 284 tempitem.misc8 = 0;
8088 284 tempitem.misc9 = 0;
8089 284 tempitem.misc10 = 0;
8090 284 tempitem.wpn = 0;
8091 284 tempitem.wpn2 = 0;
8092 284 tempitem.wpn3 = 0;
8093 284 tempitem.wpn4 = 0;
8094 284 tempitem.wpn5 = 0;
8095 284 tempitem.wpn6 = 0;
8096 284 tempitem.wpn7 = 0;
8097 284 tempitem.wpn8 = 0;
8098 284 tempitem.wpn9 = 0;
8099 284 tempitem.wpn10 = 0;
8100 284 break;
8101 }
8102 case itype_bracelet:
8103 {
8104 861 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8105 861 tempitem.misc1 = 0;
8106 861 tempitem.misc2 = 0;
8107 861 tempitem.misc3 = 0;
8108 861 tempitem.misc4 = 0;
8109 861 tempitem.misc5 = 0;
8110 861 tempitem.misc6 = 0;
8111 861 tempitem.misc7 = 0;
8112 861 tempitem.misc8 = 0;
8113 861 tempitem.misc9 = 0;
8114 861 tempitem.misc10 = 0;
8115 861 tempitem.wpn = 0;
8116 861 tempitem.wpn2 = 0;
8117 861 tempitem.wpn3 = 0;
8118 861 tempitem.wpn4 = 0;
8119 861 tempitem.wpn5 = 0;
8120 861 tempitem.wpn6 = 0;
8121 861 tempitem.wpn7 = 0;
8122 861 tempitem.wpn8 = 0;
8123 861 tempitem.wpn9 = 0;
8124 861 tempitem.wpn10 = 0;
8125 861 break;
8126 }
8127 case itype_flippers:
8128 {
8129 287 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8130 287 tempitem.misc1 = 0;
8131 287 tempitem.misc2 = 0;
8132 287 tempitem.misc3 = 0;
8133 287 tempitem.misc4 = 0;
8134 287 tempitem.misc5 = 0;
8135 287 tempitem.misc6 = 0;
8136 287 tempitem.misc7 = 0;
8137 287 tempitem.misc8 = 0;
8138 287 tempitem.misc9 = 0;
8139 287 tempitem.misc10 = 0;
8140 287 tempitem.wpn = 0;
8141 287 tempitem.wpn2 = 0;
8142 287 tempitem.wpn3 = 0;
8143 287 tempitem.wpn4 = 0;
8144 287 tempitem.wpn5 = 0;
8145 287 tempitem.wpn6 = 0;
8146 287 tempitem.wpn7 = 0;
8147 287 tempitem.wpn8 = 0;
8148 287 tempitem.wpn9 = 0;
8149 287 tempitem.wpn10 = 0;
8150 287 break;
8151 }
8152 case itype_boots:
8153 {
8154 290 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8155 290 tempitem.misc1 = 0;
8156 290 tempitem.misc2 = 0;
8157 290 tempitem.misc3 = 0;
8158 290 tempitem.misc4 = 0;
8159 290 tempitem.misc5 = 0;
8160 290 tempitem.misc6 = 0;
8161 290 tempitem.misc7 = 0;
8162 290 tempitem.misc8 = 0;
8163 290 tempitem.misc9 = 0;
8164 290 tempitem.misc10 = 0;
8165 290 tempitem.wpn = 0;
8166 290 tempitem.wpn2 = 0;
8167 290 tempitem.wpn3 = 0;
8168 290 tempitem.wpn4 = 0;
8169 290 tempitem.wpn5 = 0;
8170 290 tempitem.wpn6 = 0;
8171 290 tempitem.wpn7 = 0;
8172 290 tempitem.wpn8 = 0;
8173 290 tempitem.wpn9 = 0;
8174 290 tempitem.wpn10 = 0;
8175 290 break;
8176 }
8177 case itype_hookshot:
8178 {
8179 570 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8180 570 tempitem.misc5 = 0;
8181 570 tempitem.misc6 = 0;
8182 570 tempitem.misc7 = 0;
8183 570 tempitem.misc8 = 0;
8184 570 tempitem.misc9 = 0;
8185 570 tempitem.misc10 = 0;
8186 570 tempitem.wpn5 = 0;
8187 570 tempitem.wpn6 = 0;
8188 570 tempitem.wpn7 = 0;
8189 570 tempitem.wpn8 = 0;
8190 570 tempitem.wpn9 = 0;
8191 570 tempitem.wpn10 = 0;
8192 570 break;
8193 }
8194 case itype_lens:
8195 {
8196 260 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8197 260 tempitem.misc2 = 0;
8198 260 tempitem.misc3 = 0;
8199 260 tempitem.misc4 = 0;
8200 260 tempitem.misc5 = 0;
8201 260 tempitem.misc6 = 0;
8202 260 tempitem.misc7 = 0;
8203 260 tempitem.misc8 = 0;
8204 260 tempitem.misc9 = 0;
8205 260 tempitem.misc10 = 0;
8206 260 tempitem.wpn = 0;
8207 260 tempitem.wpn2 = 0;
8208 260 tempitem.wpn3 = 0;
8209 260 tempitem.wpn4 = 0;
8210 260 tempitem.wpn5 = 0;
8211 260 tempitem.wpn6 = 0;
8212 260 tempitem.wpn7 = 0;
8213 260 tempitem.wpn8 = 0;
8214 260 tempitem.wpn9 = 0;
8215 260 tempitem.wpn10 = 0;
8216 260 break;
8217 }
8218 case itype_hammer:
8219 {
8220 287 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8221 287 tempitem.misc1 = 0;
8222 287 tempitem.misc2 = 0;
8223 287 tempitem.misc3 = 0;
8224 287 tempitem.misc4 = 0;
8225 287 tempitem.misc5 = 0;
8226 287 tempitem.misc6 = 0;
8227 287 tempitem.misc7 = 0;
8228 287 tempitem.misc8 = 0;
8229 287 tempitem.misc9 = 0;
8230 287 tempitem.misc10 = 0;
8231 287 tempitem.wpn3 = 0;
8232 287 tempitem.wpn4 = 0;
8233 287 tempitem.wpn5 = 0;
8234 287 tempitem.wpn6 = 0;
8235 287 tempitem.wpn7 = 0;
8236 287 tempitem.wpn8 = 0;
8237 287 tempitem.wpn9 = 0;
8238 287 tempitem.wpn10 = 0;
8239 287 break;
8240 }
8241 case itype_divinefire:
8242 {
8243 284 tempitem.flags &= ~ (item_flag1 | item_flag4 | item_flag5);
8244 284 tempitem.misc3 = 0;
8245 284 tempitem.misc4 = 0;
8246 284 tempitem.misc5 = 0;
8247 284 tempitem.misc6 = 0;
8248 284 tempitem.misc7 = 0;
8249 284 tempitem.misc8 = 0;
8250 284 tempitem.misc9 = 0;
8251 284 tempitem.misc10 = 0;
8252 284 tempitem.wpn6 = 0;
8253 284 tempitem.wpn7 = 0;
8254 284 tempitem.wpn8 = 0;
8255 284 tempitem.wpn9 = 0;
8256 284 tempitem.wpn10 = 0;
8257 284 break;
8258 }
8259 case itype_divineescape:
8260 {
8261 284 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8262 284 tempitem.misc2 = 0;
8263 284 tempitem.misc3 = 0;
8264 284 tempitem.misc4 = 0;
8265 284 tempitem.misc5 = 0;
8266 284 tempitem.misc6 = 0;
8267 284 tempitem.misc7 = 0;
8268 284 tempitem.misc8 = 0;
8269 284 tempitem.misc9 = 0;
8270 284 tempitem.misc10 = 0;
8271 284 tempitem.wpn = 0;
8272 284 tempitem.wpn2 = 0;
8273 284 tempitem.wpn3 = 0;
8274 284 tempitem.wpn4 = 0;
8275 284 tempitem.wpn5 = 0;
8276 284 tempitem.wpn6 = 0;
8277 284 tempitem.wpn7 = 0;
8278 284 tempitem.wpn8 = 0;
8279 284 tempitem.wpn9 = 0;
8280 284 tempitem.wpn10 = 0;
8281 284 break;
8282 }
8283 case itype_divineprotection:
8284 {
8285 284 tempitem.flags &= ~ (item_flag5);
8286 284 tempitem.misc2 = 0;
8287 284 tempitem.misc3 = 0;
8288 284 tempitem.misc4 = 0;
8289 284 tempitem.misc5 = 0;
8290 284 tempitem.misc6 = 0;
8291 284 tempitem.misc7 = 0;
8292 284 tempitem.misc8 = 0;
8293 284 tempitem.misc9 = 0;
8294 284 tempitem.misc10 = 0;
8295 284 break;
8296 }
8297 case itype_bomb:
8298 {
8299 300 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8300 300 tempitem.misc4 = 0;
8301 300 tempitem.misc5 = 0;
8302 300 tempitem.misc6 = 0;
8303 300 tempitem.misc7 = 0;
8304 300 tempitem.misc8 = 0;
8305 300 tempitem.misc9 = 0;
8306 300 tempitem.misc10 = 0;
8307 300 tempitem.wpn3 = 0;
8308 300 tempitem.wpn4 = 0;
8309 300 tempitem.wpn5 = 0;
8310 300 tempitem.wpn6 = 0;
8311 300 tempitem.wpn7 = 0;
8312 300 tempitem.wpn8 = 0;
8313 300 tempitem.wpn9 = 0;
8314 300 tempitem.wpn10 = 0;
8315 300 break;
8316 }
8317 case itype_sbomb:
8318 {
8319 286 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8320 286 tempitem.misc4 = 0;
8321 286 tempitem.misc5 = 0;
8322 286 tempitem.misc6 = 0;
8323 286 tempitem.misc7 = 0;
8324 286 tempitem.misc8 = 0;
8325 286 tempitem.misc9 = 0;
8326 286 tempitem.misc10 = 0;
8327 286 tempitem.wpn3 = 0;
8328 286 tempitem.wpn4 = 0;
8329 286 tempitem.wpn5 = 0;
8330 286 tempitem.wpn6 = 0;
8331 286 tempitem.wpn7 = 0;
8332 286 tempitem.wpn8 = 0;
8333 286 tempitem.wpn9 = 0;
8334 286 tempitem.wpn10 = 0;
8335 286 break;
8336 }
8337 case itype_clock:
8338 {
8339 287 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8340 287 tempitem.misc2 = 0;
8341 287 tempitem.misc3 = 0;
8342 287 tempitem.misc4 = 0;
8343 287 tempitem.misc5 = 0;
8344 287 tempitem.misc6 = 0;
8345 287 tempitem.misc7 = 0;
8346 287 tempitem.misc8 = 0;
8347 287 tempitem.misc9 = 0;
8348 287 tempitem.misc10 = 0;
8349 287 tempitem.wpn = 0;
8350 287 tempitem.wpn2 = 0;
8351 287 tempitem.wpn3 = 0;
8352 287 tempitem.wpn4 = 0;
8353 287 tempitem.wpn5 = 0;
8354 287 tempitem.wpn6 = 0;
8355 287 tempitem.wpn7 = 0;
8356 287 tempitem.wpn8 = 0;
8357 287 tempitem.wpn9 = 0;
8358 287 tempitem.wpn10 = 0;
8359 287 break;
8360 }
8361 case itype_key:
8362 {
8363 284 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8364 284 tempitem.misc1 = 0;
8365 284 tempitem.misc2 = 0;
8366 284 tempitem.misc3 = 0;
8367 284 tempitem.misc4 = 0;
8368 284 tempitem.misc5 = 0;
8369 284 tempitem.misc6 = 0;
8370 284 tempitem.misc7 = 0;
8371 284 tempitem.misc8 = 0;
8372 284 tempitem.misc9 = 0;
8373 284 tempitem.misc10 = 0;
8374 284 tempitem.wpn = 0;
8375 284 tempitem.wpn2 = 0;
8376 284 tempitem.wpn3 = 0;
8377 284 tempitem.wpn4 = 0;
8378 284 tempitem.wpn5 = 0;
8379 284 tempitem.wpn6 = 0;
8380 284 tempitem.wpn7 = 0;
8381 284 tempitem.wpn8 = 0;
8382 284 tempitem.wpn9 = 0;
8383 284 tempitem.wpn10 = 0;
8384 284 break;
8385 }
8386 case itype_magiccontainer:
8387 {
8388 289 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8389 289 tempitem.misc1 = 0;
8390 289 tempitem.misc2 = 0;
8391 289 tempitem.misc3 = 0;
8392 289 tempitem.misc4 = 0;
8393 289 tempitem.misc5 = 0;
8394 289 tempitem.misc6 = 0;
8395 289 tempitem.misc7 = 0;
8396 289 tempitem.misc8 = 0;
8397 289 tempitem.misc9 = 0;
8398 289 tempitem.misc10 = 0;
8399 289 tempitem.wpn = 0;
8400 289 tempitem.wpn2 = 0;
8401 289 tempitem.wpn3 = 0;
8402 289 tempitem.wpn4 = 0;
8403 289 tempitem.wpn5 = 0;
8404 289 tempitem.wpn6 = 0;
8405 289 tempitem.wpn7 = 0;
8406 289 tempitem.wpn8 = 0;
8407 289 tempitem.wpn9 = 0;
8408 289 tempitem.wpn10 = 0;
8409 289 break;
8410 }
8411 case itype_triforcepiece:
8412 {
8413 568 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8414 568 tempitem.misc3 = 0;
8415 568 tempitem.misc4 = 0;
8416 568 tempitem.misc5 = 0;
8417 568 tempitem.misc6 = 0;
8418 568 tempitem.misc7 = 0;
8419 568 tempitem.misc8 = 0;
8420 568 tempitem.misc9 = 0;
8421 568 tempitem.misc10 = 0;
8422 568 tempitem.wpn = 0;
8423 568 tempitem.wpn2 = 0;
8424 568 tempitem.wpn3 = 0;
8425 568 tempitem.wpn4 = 0;
8426 568 tempitem.wpn5 = 0;
8427 568 tempitem.wpn6 = 0;
8428 568 tempitem.wpn7 = 0;
8429 568 tempitem.wpn8 = 0;
8430 568 tempitem.wpn9 = 0;
8431 568 tempitem.wpn10 = 0;
8432 568 break;
8433 }
8434 case itype_map: case itype_compass: case itype_bosskey:
8435 {
8436 857 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8437 857 tempitem.misc1 = 0;
8438 857 tempitem.misc2 = 0;
8439 857 tempitem.misc3 = 0;
8440 857 tempitem.misc4 = 0;
8441 857 tempitem.misc5 = 0;
8442 857 tempitem.misc6 = 0;
8443 857 tempitem.misc7 = 0;
8444 857 tempitem.misc8 = 0;
8445 857 tempitem.misc9 = 0;
8446 857 tempitem.misc10 = 0;
8447 857 tempitem.wpn = 0;
8448 857 tempitem.wpn2 = 0;
8449 857 tempitem.wpn3 = 0;
8450 857 tempitem.wpn4 = 0;
8451 857 tempitem.wpn5 = 0;
8452 857 tempitem.wpn6 = 0;
8453 857 tempitem.wpn7 = 0;
8454 857 tempitem.wpn8 = 0;
8455 857 tempitem.wpn9 = 0;
8456 857 tempitem.wpn10 = 0;
8457 857 break;
8458 }
8459 case itype_quiver:
8460 {
8461 1136 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8462 1136 tempitem.misc3 = 0;
8463 1136 tempitem.misc4 = 0;
8464 1136 tempitem.misc5 = 0;
8465 1136 tempitem.misc6 = 0;
8466 1136 tempitem.misc7 = 0;
8467 1136 tempitem.misc8 = 0;
8468 1136 tempitem.misc9 = 0;
8469 1136 tempitem.misc10 = 0;
8470 1136 tempitem.wpn = 0;
8471 1136 tempitem.wpn2 = 0;
8472 1136 tempitem.wpn3 = 0;
8473 1136 tempitem.wpn4 = 0;
8474 1136 tempitem.wpn5 = 0;
8475 1136 tempitem.wpn6 = 0;
8476 1136 tempitem.wpn7 = 0;
8477 1136 tempitem.wpn8 = 0;
8478 1136 tempitem.wpn9 = 0;
8479 1136 tempitem.wpn10 = 0;
8480 1136 break;
8481 }
8482 case itype_lkey:
8483 {
8484 785 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8485 785 tempitem.misc1 = 0;
8486 785 tempitem.misc2 = 0;
8487 785 tempitem.misc3 = 0;
8488 785 tempitem.misc4 = 0;
8489 785 tempitem.misc5 = 0;
8490 785 tempitem.misc6 = 0;
8491 785 tempitem.misc7 = 0;
8492 785 tempitem.misc8 = 0;
8493 785 tempitem.misc9 = 0;
8494 785 tempitem.misc10 = 0;
8495 785 tempitem.wpn = 0;
8496 785 tempitem.wpn2 = 0;
8497 785 tempitem.wpn3 = 0;
8498 785 tempitem.wpn4 = 0;
8499 785 tempitem.wpn5 = 0;
8500 785 tempitem.wpn6 = 0;
8501 785 tempitem.wpn7 = 0;
8502 785 tempitem.wpn8 = 0;
8503 785 tempitem.wpn9 = 0;
8504 785 tempitem.wpn10 = 0;
8505 785 break;
8506 }
8507 case itype_cbyrna:
8508 {
8509 284 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag5);
8510 284 tempitem.misc4 = 0;
8511 284 tempitem.misc5 = 0;
8512 284 tempitem.misc6 = 0;
8513 284 tempitem.misc7 = 0;
8514 284 tempitem.misc8 = 0;
8515 284 tempitem.misc9 = 0;
8516 284 tempitem.misc10 = 0;
8517 284 tempitem.wpn6 = 0;
8518 284 tempitem.wpn7 = 0;
8519 284 tempitem.wpn8 = 0;
8520 284 tempitem.wpn9 = 0;
8521 284 tempitem.wpn10 = 0;
8522 284 break;
8523 }
8524 case itype_rupee: case itype_arrowammo:
8525 {
8526 3317 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8527 3317 tempitem.misc1 = 0;
8528 3317 tempitem.misc2 = 0;
8529 3317 tempitem.misc3 = 0;
8530 3317 tempitem.misc4 = 0;
8531 3317 tempitem.misc5 = 0;
8532 3317 tempitem.misc6 = 0;
8533 3317 tempitem.misc7 = 0;
8534 3317 tempitem.misc8 = 0;
8535 3317 tempitem.misc9 = 0;
8536 3317 tempitem.misc10 = 0;
8537 3317 tempitem.wpn = 0;
8538 3317 tempitem.wpn2 = 0;
8539 3317 tempitem.wpn3 = 0;
8540 3317 tempitem.wpn4 = 0;
8541 3317 tempitem.wpn5 = 0;
8542 3317 tempitem.wpn6 = 0;
8543 3317 tempitem.wpn7 = 0;
8544 3317 tempitem.wpn8 = 0;
8545 3317 tempitem.wpn9 = 0;
8546 3317 tempitem.wpn10 = 0;
8547 3317 break;
8548 }
8549 case itype_fairy:
8550 {
8551 555 tempitem.flags &= ~ (item_flag3 | item_flag4 | item_flag5);
8552 555 tempitem.misc4 = 0;
8553 555 tempitem.misc5 = 0;
8554 555 tempitem.misc6 = 0;
8555 555 tempitem.misc7 = 0;
8556 555 tempitem.misc8 = 0;
8557 555 tempitem.misc9 = 0;
8558 555 tempitem.misc10 = 0;
8559 555 tempitem.wpn = 0;
8560 555 tempitem.wpn2 = 0;
8561 555 tempitem.wpn3 = 0;
8562 555 tempitem.wpn4 = 0;
8563 555 tempitem.wpn5 = 0;
8564 555 tempitem.wpn6 = 0;
8565 555 tempitem.wpn7 = 0;
8566 555 tempitem.wpn8 = 0;
8567 555 tempitem.wpn9 = 0;
8568 555 tempitem.wpn10 = 0;
8569 555 break;
8570 }
8571 case itype_magic: case itype_heart: case itype_heartcontainer: case itype_heartpiece: case itype_killem: case itype_bombammo:
8572 {
8573 2923 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8574 2923 tempitem.misc1 = 0;
8575 2923 tempitem.misc2 = 0;
8576 2923 tempitem.misc3 = 0;
8577 2923 tempitem.misc4 = 0;
8578 2923 tempitem.misc5 = 0;
8579 2923 tempitem.misc6 = 0;
8580 2923 tempitem.misc7 = 0;
8581 2923 tempitem.misc8 = 0;
8582 2923 tempitem.misc9 = 0;
8583 2923 tempitem.misc10 = 0;
8584 2923 tempitem.wpn = 0;
8585 2923 tempitem.wpn2 = 0;
8586 2923 tempitem.wpn3 = 0;
8587 2923 tempitem.wpn4 = 0;
8588 2923 tempitem.wpn5 = 0;
8589 2923 tempitem.wpn6 = 0;
8590 2923 tempitem.wpn7 = 0;
8591 2923 tempitem.wpn8 = 0;
8592 2923 tempitem.wpn9 = 0;
8593 2923 tempitem.wpn10 = 0;
8594 2923 break;
8595 }
8596 case itype_bombbag:
8597 {
8598 1136 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8599 1136 tempitem.misc3 = 0;
8600 1136 tempitem.misc4 = 0;
8601 1136 tempitem.misc5 = 0;
8602 1136 tempitem.misc6 = 0;
8603 1136 tempitem.misc7 = 0;
8604 1136 tempitem.misc8 = 0;
8605 1136 tempitem.misc9 = 0;
8606 1136 tempitem.misc10 = 0;
8607 1136 tempitem.wpn = 0;
8608 1136 tempitem.wpn2 = 0;
8609 1136 tempitem.wpn3 = 0;
8610 1136 tempitem.wpn4 = 0;
8611 1136 tempitem.wpn5 = 0;
8612 1136 tempitem.wpn6 = 0;
8613 1136 tempitem.wpn7 = 0;
8614 1136 tempitem.wpn8 = 0;
8615 1136 tempitem.wpn9 = 0;
8616 1136 tempitem.wpn10 = 0;
8617 1136 break;
8618 }
8619 case itype_rocs:
8620 {
8621 284 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8622 284 tempitem.misc1 = 0;
8623 284 tempitem.misc2 = 0;
8624 284 tempitem.misc3 = 0;
8625 284 tempitem.misc4 = 0;
8626 284 tempitem.misc5 = 0;
8627 284 tempitem.misc6 = 0;
8628 284 tempitem.misc7 = 0;
8629 284 tempitem.misc8 = 0;
8630 284 tempitem.misc9 = 0;
8631 284 tempitem.misc10 = 0;
8632 284 tempitem.wpn = 0;
8633 284 tempitem.wpn2 = 0;
8634 284 tempitem.wpn3 = 0;
8635 284 tempitem.wpn4 = 0;
8636 284 tempitem.wpn5 = 0;
8637 284 tempitem.wpn6 = 0;
8638 284 tempitem.wpn7 = 0;
8639 284 tempitem.wpn8 = 0;
8640 284 tempitem.wpn9 = 0;
8641 284 tempitem.wpn10 = 0;
8642 284 break;
8643 }
8644 case itype_hoverboots:
8645 {
8646 284 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8647 284 tempitem.misc2 = 0;
8648 284 tempitem.misc3 = 0;
8649 284 tempitem.misc4 = 0;
8650 284 tempitem.misc5 = 0;
8651 284 tempitem.misc6 = 0;
8652 284 tempitem.misc7 = 0;
8653 284 tempitem.misc8 = 0;
8654 284 tempitem.misc9 = 0;
8655 284 tempitem.misc10 = 0;
8656 284 tempitem.wpn2 = 0;
8657 284 tempitem.wpn3 = 0;
8658 284 tempitem.wpn4 = 0;
8659 284 tempitem.wpn5 = 0;
8660 284 tempitem.wpn6 = 0;
8661 284 tempitem.wpn7 = 0;
8662 284 tempitem.wpn8 = 0;
8663 284 tempitem.wpn9 = 0;
8664 284 tempitem.wpn10 = 0;
8665 284 break;
8666 }
8667 case itype_spinscroll:
8668 {
8669 284 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8670 284 tempitem.misc2 = 0;
8671 284 tempitem.misc3 = 0;
8672 284 tempitem.misc4 = 0;
8673 284 tempitem.misc5 = 0;
8674 284 tempitem.misc6 = 0;
8675 284 tempitem.misc7 = 0;
8676 284 tempitem.misc8 = 0;
8677 284 tempitem.misc9 = 0;
8678 284 tempitem.misc10 = 0;
8679 284 tempitem.wpn = 0;
8680 284 tempitem.wpn2 = 0;
8681 284 tempitem.wpn3 = 0;
8682 284 tempitem.wpn4 = 0;
8683 284 tempitem.wpn5 = 0;
8684 284 tempitem.wpn6 = 0;
8685 284 tempitem.wpn7 = 0;
8686 284 tempitem.wpn8 = 0;
8687 284 tempitem.wpn9 = 0;
8688 284 tempitem.wpn10 = 0;
8689 284 break;
8690 }
8691 case itype_crossscroll:
8692 {
8693 284 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8694 284 tempitem.misc1 = 0;
8695 284 tempitem.misc2 = 0;
8696 284 tempitem.misc3 = 0;
8697 284 tempitem.misc4 = 0;
8698 284 tempitem.misc5 = 0;
8699 284 tempitem.misc6 = 0;
8700 284 tempitem.misc7 = 0;
8701 284 tempitem.misc8 = 0;
8702 284 tempitem.misc9 = 0;
8703 284 tempitem.misc10 = 0;
8704 284 tempitem.wpn = 0;
8705 284 tempitem.wpn2 = 0;
8706 284 tempitem.wpn3 = 0;
8707 284 tempitem.wpn4 = 0;
8708 284 tempitem.wpn5 = 0;
8709 284 tempitem.wpn6 = 0;
8710 284 tempitem.wpn7 = 0;
8711 284 tempitem.wpn8 = 0;
8712 284 tempitem.wpn9 = 0;
8713 284 tempitem.wpn10 = 0;
8714 284 break;
8715 }
8716 case itype_quakescroll:
8717 {
8718 284 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8719 284 tempitem.misc3 = 0;
8720 284 tempitem.misc4 = 0;
8721 284 tempitem.misc5 = 0;
8722 284 tempitem.misc6 = 0;
8723 284 tempitem.misc7 = 0;
8724 284 tempitem.misc8 = 0;
8725 284 tempitem.misc9 = 0;
8726 284 tempitem.misc10 = 0;
8727 284 tempitem.wpn = 0;
8728 284 tempitem.wpn2 = 0;
8729 284 tempitem.wpn3 = 0;
8730 284 tempitem.wpn4 = 0;
8731 284 tempitem.wpn5 = 0;
8732 284 tempitem.wpn6 = 0;
8733 284 tempitem.wpn7 = 0;
8734 284 tempitem.wpn8 = 0;
8735 284 tempitem.wpn9 = 0;
8736 284 tempitem.wpn10 = 0;
8737 284 break;
8738 }
8739 case itype_whispring:
8740 {
8741 571 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8742 571 tempitem.misc2 = 0;
8743 571 tempitem.misc3 = 0;
8744 571 tempitem.misc4 = 0;
8745 571 tempitem.misc5 = 0;
8746 571 tempitem.misc6 = 0;
8747 571 tempitem.misc7 = 0;
8748 571 tempitem.misc8 = 0;
8749 571 tempitem.misc9 = 0;
8750 571 tempitem.misc10 = 0;
8751 571 tempitem.wpn = 0;
8752 571 tempitem.wpn2 = 0;
8753 571 tempitem.wpn3 = 0;
8754 571 tempitem.wpn4 = 0;
8755 571 tempitem.wpn5 = 0;
8756 571 tempitem.wpn6 = 0;
8757 571 tempitem.wpn7 = 0;
8758 571 tempitem.wpn8 = 0;
8759 571 tempitem.wpn9 = 0;
8760 571 tempitem.wpn10 = 0;
8761 571 break;
8762 }
8763 case itype_chargering:
8764 {
8765 568 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8766 568 tempitem.misc3 = 0;
8767 568 tempitem.misc4 = 0;
8768 568 tempitem.misc5 = 0;
8769 568 tempitem.misc6 = 0;
8770 568 tempitem.misc7 = 0;
8771 568 tempitem.misc8 = 0;
8772 568 tempitem.misc9 = 0;
8773 568 tempitem.misc10 = 0;
8774 568 tempitem.wpn = 0;
8775 568 tempitem.wpn2 = 0;
8776 568 tempitem.wpn3 = 0;
8777 568 tempitem.wpn4 = 0;
8778 568 tempitem.wpn5 = 0;
8779 568 tempitem.wpn6 = 0;
8780 568 tempitem.wpn7 = 0;
8781 568 tempitem.wpn8 = 0;
8782 568 tempitem.wpn9 = 0;
8783 568 tempitem.wpn10 = 0;
8784 568 break;
8785 }
8786 case itype_perilscroll:
8787 {
8788 284 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8789 284 tempitem.misc2 = 0;
8790 284 tempitem.misc3 = 0;
8791 284 tempitem.misc4 = 0;
8792 284 tempitem.misc5 = 0;
8793 284 tempitem.misc6 = 0;
8794 284 tempitem.misc7 = 0;
8795 284 tempitem.misc8 = 0;
8796 284 tempitem.misc9 = 0;
8797 284 tempitem.misc10 = 0;
8798 284 tempitem.wpn = 0;
8799 284 tempitem.wpn2 = 0;
8800 284 tempitem.wpn3 = 0;
8801 284 tempitem.wpn4 = 0;
8802 284 tempitem.wpn5 = 0;
8803 284 tempitem.wpn6 = 0;
8804 284 tempitem.wpn7 = 0;
8805 284 tempitem.wpn8 = 0;
8806 284 tempitem.wpn9 = 0;
8807 284 tempitem.wpn10 = 0;
8808 284 break;
8809 }
8810 case itype_wealthmedal:
8811 {
8812 855 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8813 855 tempitem.misc2 = 0;
8814 855 tempitem.misc3 = 0;
8815 855 tempitem.misc4 = 0;
8816 855 tempitem.misc5 = 0;
8817 855 tempitem.misc6 = 0;
8818 855 tempitem.misc7 = 0;
8819 855 tempitem.misc8 = 0;
8820 855 tempitem.misc9 = 0;
8821 855 tempitem.misc10 = 0;
8822 855 tempitem.wpn = 0;
8823 855 tempitem.wpn2 = 0;
8824 855 tempitem.wpn3 = 0;
8825 855 tempitem.wpn4 = 0;
8826 855 tempitem.wpn5 = 0;
8827 855 tempitem.wpn6 = 0;
8828 855 tempitem.wpn7 = 0;
8829 855 tempitem.wpn8 = 0;
8830 855 tempitem.wpn9 = 0;
8831 855 tempitem.wpn10 = 0;
8832 855 break;
8833 }
8834 case itype_heartring:
8835 {
8836 858 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8837 858 tempitem.misc3 = 0;
8838 858 tempitem.misc4 = 0;
8839 858 tempitem.misc5 = 0;
8840 858 tempitem.misc6 = 0;
8841 858 tempitem.misc7 = 0;
8842 858 tempitem.misc8 = 0;
8843 858 tempitem.misc9 = 0;
8844 858 tempitem.misc10 = 0;
8845 858 tempitem.wpn = 0;
8846 858 tempitem.wpn2 = 0;
8847 858 tempitem.wpn3 = 0;
8848 858 tempitem.wpn4 = 0;
8849 858 tempitem.wpn5 = 0;
8850 858 tempitem.wpn6 = 0;
8851 858 tempitem.wpn7 = 0;
8852 858 tempitem.wpn8 = 0;
8853 858 tempitem.wpn9 = 0;
8854 858 tempitem.wpn10 = 0;
8855 858 break;
8856 }
8857 case itype_magicring:
8858 {
8859 1148 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8860 1148 tempitem.misc3 = 0;
8861 1148 tempitem.misc4 = 0;
8862 1148 tempitem.misc5 = 0;
8863 1148 tempitem.misc6 = 0;
8864 1148 tempitem.misc7 = 0;
8865 1148 tempitem.misc8 = 0;
8866 1148 tempitem.misc9 = 0;
8867 1148 tempitem.misc10 = 0;
8868 1148 tempitem.wpn = 0;
8869 1148 tempitem.wpn2 = 0;
8870 1148 tempitem.wpn3 = 0;
8871 1148 tempitem.wpn4 = 0;
8872 1148 tempitem.wpn5 = 0;
8873 1148 tempitem.wpn6 = 0;
8874 1148 tempitem.wpn7 = 0;
8875 1148 tempitem.wpn8 = 0;
8876 1148 tempitem.wpn9 = 0;
8877 1148 tempitem.wpn10 = 0;
8878 1148 break;
8879 }
8880 case itype_spinscroll2:
8881 {
8882 284 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8883 284 tempitem.misc2 = 0;
8884 284 tempitem.misc3 = 0;
8885 284 tempitem.misc4 = 0;
8886 284 tempitem.misc5 = 0;
8887 284 tempitem.misc6 = 0;
8888 284 tempitem.misc7 = 0;
8889 284 tempitem.misc8 = 0;
8890 284 tempitem.misc9 = 0;
8891 284 tempitem.misc10 = 0;
8892 284 tempitem.wpn = 0;
8893 284 tempitem.wpn2 = 0;
8894 284 tempitem.wpn3 = 0;
8895 284 tempitem.wpn4 = 0;
8896 284 tempitem.wpn5 = 0;
8897 284 tempitem.wpn6 = 0;
8898 284 tempitem.wpn7 = 0;
8899 284 tempitem.wpn8 = 0;
8900 284 tempitem.wpn9 = 0;
8901 284 tempitem.wpn10 = 0;
8902 284 break;
8903 }
8904 case itype_quakescroll2:
8905 {
8906 284 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8907 284 tempitem.misc3 = 0;
8908 284 tempitem.misc4 = 0;
8909 284 tempitem.misc5 = 0;
8910 284 tempitem.misc6 = 0;
8911 284 tempitem.misc7 = 0;
8912 284 tempitem.misc8 = 0;
8913 284 tempitem.misc9 = 0;
8914 284 tempitem.misc10 = 0;
8915 284 tempitem.wpn = 0;
8916 284 tempitem.wpn2 = 0;
8917 284 tempitem.wpn3 = 0;
8918 284 tempitem.wpn4 = 0;
8919 284 tempitem.wpn5 = 0;
8920 284 tempitem.wpn6 = 0;
8921 284 tempitem.wpn7 = 0;
8922 284 tempitem.wpn8 = 0;
8923 284 tempitem.wpn9 = 0;
8924 284 tempitem.wpn10 = 0;
8925 284 break;
8926 }
8927 case itype_agony:
8928 {
8929 284 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8930 284 tempitem.misc2 = 0;
8931 284 tempitem.misc3 = 0;
8932 284 tempitem.misc4 = 0;
8933 284 tempitem.misc5 = 0;
8934 284 tempitem.misc6 = 0;
8935 284 tempitem.misc7 = 0;
8936 284 tempitem.misc8 = 0;
8937 284 tempitem.misc9 = 0;
8938 284 tempitem.misc10 = 0;
8939 284 tempitem.wpn = 0;
8940 284 tempitem.wpn2 = 0;
8941 284 tempitem.wpn3 = 0;
8942 284 tempitem.wpn4 = 0;
8943 284 tempitem.wpn5 = 0;
8944 284 tempitem.wpn6 = 0;
8945 284 tempitem.wpn7 = 0;
8946 284 tempitem.wpn8 = 0;
8947 284 tempitem.wpn9 = 0;
8948 284 tempitem.wpn10 = 0;
8949 284 break;
8950 }
8951 case itype_stompboots:
8952 {
8953 284 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8954 284 tempitem.misc1 = 0;
8955 284 tempitem.misc2 = 0;
8956 284 tempitem.misc3 = 0;
8957 284 tempitem.misc4 = 0;
8958 284 tempitem.misc5 = 0;
8959 284 tempitem.misc6 = 0;
8960 284 tempitem.misc7 = 0;
8961 284 tempitem.misc8 = 0;
8962 284 tempitem.misc9 = 0;
8963 284 tempitem.misc10 = 0;
8964 284 tempitem.wpn = 0;
8965 284 tempitem.wpn2 = 0;
8966 284 tempitem.wpn3 = 0;
8967 284 tempitem.wpn4 = 0;
8968 284 tempitem.wpn5 = 0;
8969 284 tempitem.wpn6 = 0;
8970 284 tempitem.wpn7 = 0;
8971 284 tempitem.wpn8 = 0;
8972 284 tempitem.wpn9 = 0;
8973 284 tempitem.wpn10 = 0;
8974 284 break;
8975 }
8976 case itype_whimsicalring:
8977 {
8978 284 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8979 284 tempitem.misc2 = 0;
8980 284 tempitem.misc3 = 0;
8981 284 tempitem.misc4 = 0;
8982 284 tempitem.misc5 = 0;
8983 284 tempitem.misc6 = 0;
8984 284 tempitem.misc7 = 0;
8985 284 tempitem.misc8 = 0;
8986 284 tempitem.misc9 = 0;
8987 284 tempitem.misc10 = 0;
8988 284 tempitem.wpn = 0;
8989 284 tempitem.wpn2 = 0;
8990 284 tempitem.wpn3 = 0;
8991 284 tempitem.wpn4 = 0;
8992 284 tempitem.wpn5 = 0;
8993 284 tempitem.wpn6 = 0;
8994 284 tempitem.wpn7 = 0;
8995 284 tempitem.wpn8 = 0;
8996 284 tempitem.wpn9 = 0;
8997 284 tempitem.wpn10 = 0;
8998 284 break;
8999 }
9000 case itype_perilring:
9001 {
9002 311 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
9003 311 tempitem.misc2 = 0;
9004 311 tempitem.misc3 = 0;
9005 311 tempitem.misc4 = 0;
9006 311 tempitem.misc5 = 0;
9007 311 tempitem.misc6 = 0;
9008 311 tempitem.misc7 = 0;
9009 311 tempitem.misc8 = 0;
9010 311 tempitem.misc9 = 0;
9011 311 tempitem.misc10 = 0;
9012 311 tempitem.wpn = 0;
9013 311 tempitem.wpn2 = 0;
9014 311 tempitem.wpn3 = 0;
9015 311 tempitem.wpn4 = 0;
9016 311 tempitem.wpn5 = 0;
9017 311 tempitem.wpn6 = 0;
9018 311 tempitem.wpn7 = 0;
9019 311 tempitem.wpn8 = 0;
9020 311 tempitem.wpn9 = 0;
9021 311 tempitem.wpn10 = 0;
9022 311 break;
9023 }
9024 case itype_custom1: case itype_custom2: case itype_custom3: case itype_custom4: case itype_custom5:
9025 case itype_custom6: case itype_custom7: case itype_custom8: case itype_custom9: case itype_custom10:
9026 case itype_custom11: case itype_custom12: case itype_custom13: case itype_custom14: case itype_custom15:
9027 case itype_custom16: case itype_custom17: case itype_custom18: case itype_custom19: case itype_custom20:
9028 case itype_bowandarrow: case itype_letterpotion: case itype_misc:
9029 {
9030 10996 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
9031 10996 tempitem.misc1 = 0;
9032 10996 tempitem.misc2 = 0;
9033 10996 tempitem.misc3 = 0;
9034 10996 tempitem.misc4 = 0;
9035 10996 tempitem.misc5 = 0;
9036 10996 tempitem.misc6 = 0;
9037 10996 tempitem.misc7 = 0;
9038 10996 tempitem.misc8 = 0;
9039 10996 tempitem.misc9 = 0;
9040 10996 tempitem.misc10 = 0;
9041 10996 tempitem.wpn = 0;
9042 10996 tempitem.wpn2 = 0;
9043 10996 tempitem.wpn3 = 0;
9044 10996 tempitem.wpn4 = 0;
9045 10996 tempitem.wpn5 = 0;
9046 10996 tempitem.wpn6 = 0;
9047 10996 tempitem.wpn7 = 0;
9048 10996 tempitem.wpn8 = 0;
9049 10996 tempitem.wpn9 = 0;
9050 10996 tempitem.wpn10 = 0;
9051 10996 break;
9052 }
9053 }
9054 73472 }
9055 //Port quest rules to items
9056
2/2
✓ Branch 0 taken 48640 times.
✓ Branch 1 taken 73472 times.
122112 if( s_version <= 31)
9057 {
9058
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 73172 times.
73472 if(tempitem.family == itype_bomb)
9059 {
9060
2/2
✓ Branch 0 taken 156 times.
✓ Branch 1 taken 144 times.
300 if ( get_qr(qr_OUCHBOMBS) ) tempitem.flags |= item_flag2;
9061 144 else tempitem.flags &= ~ item_flag2;
9062 300 }
9063
2/2
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 72886 times.
73172 else if(tempitem.family == itype_sbomb)
9064 {
9065
2/2
✓ Branch 0 taken 158 times.
✓ Branch 1 taken 128 times.
286 if ( get_qr(qr_OUCHBOMBS) ) tempitem.flags |= item_flag2;
9066 128 else tempitem.flags &= ~ item_flag2;
9067 286 }
9068
9069
2/2
✓ Branch 0 taken 859 times.
✓ Branch 1 taken 72027 times.
72886 else if(tempitem.family == itype_brang)
9070 {
9071
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 859 times.
859 if ( get_qr(qr_BRANGPICKUP) ) tempitem.flags |= item_flag4;
9072 859 else tempitem.flags &= ~ item_flag4;
9073 859 }
9074
2/2
✓ Branch 0 taken 71725 times.
✓ Branch 1 taken 302 times.
72027 else if(tempitem.family == itype_wand)
9075 {
9076
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 278 times.
302 if ( get_qr(qr_NOWANDMELEE) ) tempitem.flags |= item_flag3;
9077 278 else tempitem.flags &= ~ item_flag3;
9078 302 }
9079 73472 }
9080
9081 //Port quest rules to items
9082
2/2
✓ Branch 0 taken 48640 times.
✓ Branch 1 taken 73472 times.
122112 if( s_version <= 37)
9083 {
9084
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 73185 times.
73472 if(tempitem.family == itype_flippers)
9085 {
9086
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 208 times.
287 if ( (get_qr(qr_NODIVING)) ) tempitem.flags |= item_flag1;
9087 208 else tempitem.flags &= ~ item_flag1;
9088 287 }
9089
2/2
✓ Branch 0 taken 55497 times.
✓ Branch 1 taken 17688 times.
73185 else if(tempitem.family == itype_sword)
9090 {
9091
2/2
✓ Branch 0 taken 462 times.
✓ Branch 1 taken 17226 times.
17688 if ( (get_qr(qr_QUICKSWORD)) ) tempitem.flags |= item_flag5;
9092 17226 else tempitem.flags &= ~ item_flag5;
9093 17688 }
9094
2/2
✓ Branch 0 taken 302 times.
✓ Branch 1 taken 55195 times.
55497 else if(tempitem.family == itype_wand)
9095 {
9096
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 292 times.
302 if ( (get_qr(qr_QUICKSWORD)) ) tempitem.flags |= item_flag5;
9097 292 else tempitem.flags &= ~ item_flag5;
9098 302 }
9099
4/4
✓ Branch 0 taken 54895 times.
✓ Branch 1 taken 300 times.
✓ Branch 2 taken 610 times.
✓ Branch 3 taken 54285 times.
55195 else if(tempitem.family == itype_book || tempitem.family == itype_candle)
9100 {
9101 //@Emily: What was qrFIREPROOFHERO2 again, and does that also need to enable this?
9102
2/2
✓ Branch 0 taken 381 times.
✓ Branch 1 taken 529 times.
910 if ( (get_qr(qr_FIREPROOFHERO)) ) tempitem.flags |= item_flag3;
9103 529 else tempitem.flags &= ~ item_flag3;
9104 910 }
9105 73472 }
9106
9107
2/2
✓ Branch 0 taken 48640 times.
✓ Branch 1 taken 73472 times.
122112 if( s_version < 38)
9108 {
9109
4/4
✓ Branch 0 taken 72613 times.
✓ Branch 1 taken 859 times.
✓ Branch 2 taken 570 times.
✓ Branch 3 taken 72043 times.
73472 if(tempitem.family == itype_brang || tempitem.family == itype_hookshot)
9110 {
9111
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1429 times.
1429 if(get_qr(qr_BRANGPICKUP)) tempitem.flags |= item_flag4;
9112 1429 else tempitem.flags &= ~item_flag4;
9113
9114
2/2
✓ Branch 0 taken 703 times.
✓ Branch 1 taken 726 times.
1429 if(get_qr(qr_Z3BRANG_HSHOT)) tempitem.flags |= item_flag5 | item_flag6;
9115 726 else tempitem.flags &= ~(item_flag5|item_flag6);
9116 1429 }
9117
2/2
✓ Branch 0 taken 71199 times.
✓ Branch 1 taken 844 times.
72043 else if(tempitem.family == itype_arrow)
9118 {
9119
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 844 times.
844 if(get_qr(qr_BRANGPICKUP)) tempitem.flags |= item_flag4;
9120 844 else tempitem.flags &= ~item_flag4;
9121
9122
2/2
✓ Branch 0 taken 412 times.
✓ Branch 1 taken 432 times.
844 if(get_qr(qr_Z3BRANG_HSHOT)) tempitem.flags &= ~item_flag2;
9123 432 else tempitem.flags |= item_flag2;
9124 844 }
9125 73472 }
9126
9127
2/2
✓ Branch 0 taken 48640 times.
✓ Branch 1 taken 73472 times.
122112 if( s_version < 39)
9128 {
9129
6/6
✓ Branch 0 taken 73188 times.
✓ Branch 1 taken 284 times.
✓ Branch 2 taken 72888 times.
✓ Branch 3 taken 300 times.
✓ Branch 4 taken 610 times.
✓ Branch 5 taken 72278 times.
73472 if(tempitem.family == itype_divinefire || tempitem.family == itype_book || tempitem.family == itype_candle)
9130 {
9131
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 1178 times.
1194 if(get_qr(qr_TEMPCANDLELIGHT)) tempitem.flags |= item_flag5;
9132 1178 else tempitem.flags &= ~item_flag5;
9133 1194 }
9134
2/2
✓ Branch 0 taken 623 times.
✓ Branch 1 taken 71655 times.
72278 else if(tempitem.family == itype_potion)
9135 {
9136
2/2
✓ Branch 0 taken 162 times.
✓ Branch 1 taken 461 times.
623 if(get_qr(qr_NONBUBBLEMEDICINE))
9137 {
9138 162 tempitem.flags &= ~(item_flag3|item_flag4);
9139 162 }
9140 else
9141 {
9142 461 tempitem.flags |= item_flag3;
9143
2/2
✓ Branch 0 taken 130 times.
✓ Branch 1 taken 331 times.
461 if(get_qr(qr_ITEMBUBBLE))tempitem.flags |= item_flag4;
9144 331 else tempitem.flags &= ~item_flag4;
9145 }
9146 623 }
9147
2/2
✓ Branch 0 taken 71087 times.
✓ Branch 1 taken 568 times.
71655 else if(tempitem.family == itype_triforcepiece)
9148 {
9149
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 484 times.
568 if(get_qr(qr_NONBUBBLETRIFORCE))
9150 {
9151 84 tempitem.flags |= item_flag3;
9152
2/2
✓ Branch 0 taken 56 times.
✓ Branch 1 taken 28 times.
84 if(get_qr(qr_ITEMBUBBLE))tempitem.flags |= item_flag4;
9153 28 else tempitem.flags &= ~item_flag4;
9154 84 }
9155 else
9156 {
9157 484 tempitem.flags &= ~(item_flag3|item_flag4);
9158 }
9159 568 }
9160 73472 }
9161
9162
2/2
✓ Branch 0 taken 48640 times.
✓ Branch 1 taken 73472 times.
122112 if( s_version < 40)
9163 {
9164
4/4
✓ Branch 0 taken 72540 times.
✓ Branch 1 taken 932 times.
✓ Branch 2 taken 311 times.
✓ Branch 3 taken 72229 times.
73472 if(tempitem.family == itype_ring || tempitem.family == itype_perilring)
9165 {
9166
2/2
✓ Branch 0 taken 313 times.
✓ Branch 1 taken 930 times.
1243 if(get_qr(qr_RINGAFFECTDAMAGE))tempitem.flags |= item_flag1;
9167 930 else tempitem.flags &= ~item_flag1;
9168 1243 }
9169
8/8
✓ Branch 0 taken 71619 times.
✓ Branch 1 taken 610 times.
✓ Branch 2 taken 53931 times.
✓ Branch 3 taken 17688 times.
✓ Branch 4 taken 53629 times.
✓ Branch 5 taken 302 times.
✓ Branch 6 taken 284 times.
✓ Branch 7 taken 53345 times.
72229 else if(tempitem.family == itype_candle || tempitem.family == itype_sword || tempitem.family == itype_wand || tempitem.family == itype_cbyrna)
9170 {
9171
2/2
✓ Branch 0 taken 108 times.
✓ Branch 1 taken 18776 times.
18884 if(get_qr(qr_SLASHFLIPFIX))tempitem.flags |= item_flag8;
9172 18776 else tempitem.flags &= ~item_flag8;
9173 18884 }
9174
6/6
✓ Branch 0 taken 55784 times.
✓ Branch 1 taken 17688 times.
✓ Branch 2 taken 55482 times.
✓ Branch 3 taken 302 times.
✓ Branch 4 taken 287 times.
✓ Branch 5 taken 55195 times.
73472 if(tempitem.family == itype_sword || tempitem.family == itype_wand || tempitem.family == itype_hammer)
9175 {
9176
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 18173 times.
18277 if(get_qr(qr_NOITEMMELEE))tempitem.flags |= item_flag7;
9177 18173 else tempitem.flags &= ~item_flag7;
9178 18277 }
9179
2/2
✓ Branch 0 taken 54911 times.
✓ Branch 1 taken 284 times.
55195 else if(tempitem.family == itype_cbyrna)
9180 {
9181 284 tempitem.flags |= item_flag7;
9182 284 }
9183 73472 }
9184
9185
2/2
✓ Branch 0 taken 48640 times.
✓ Branch 1 taken 73472 times.
122112 if( s_version < 41 )
9186 {
9187
2/2
✓ Branch 0 taken 55784 times.
✓ Branch 1 taken 17688 times.
73472 if(tempitem.family == itype_sword)
9188 {
9189
2/2
✓ Branch 0 taken 284 times.
✓ Branch 1 taken 17404 times.
17688 if(get_qr(qr_SWORDMIRROR))tempitem.flags |= item_flag9;
9190 17404 else tempitem.flags &= ~item_flag9;
9191
9192
2/2
✓ Branch 0 taken 428 times.
✓ Branch 1 taken 17260 times.
17688 if(get_qr(qr_SLOWCHARGINGWALK))tempitem.flags |= item_flag10;
9193 17260 else tempitem.flags &= ~item_flag10;
9194 17688 }
9195 73472 }
9196
9197
2/2
✓ Branch 0 taken 48640 times.
✓ Branch 1 taken 73472 times.
122112 if( s_version < 42 )
9198 {
9199
2/2
✓ Branch 0 taken 302 times.
✓ Branch 1 taken 73170 times.
73472 if(tempitem.family == itype_wand)
9200 {
9201
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 278 times.
302 if(get_qr(qr_NOWANDMELEE))tempitem.flags |= item_flag3;
9202 278 else tempitem.flags &= ~item_flag3;
9203
9204 302 tempitem.flags &= ~item_flag6;
9205 302 }
9206
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 72883 times.
73170 else if(tempitem.family == itype_hammer)
9207 {
9208 287 tempitem.flags &= ~item_flag3;
9209 287 }
9210
2/2
✓ Branch 0 taken 284 times.
✓ Branch 1 taken 72599 times.
72883 else if(tempitem.family == itype_cbyrna)
9211 {
9212 284 tempitem.flags |= item_flag3;
9213
9214 284 tempitem.flags &= ~item_flag6;
9215 284 }
9216
2/2
✓ Branch 0 taken 54911 times.
✓ Branch 1 taken 17688 times.
72599 else if(tempitem.family == itype_sword)
9217 {
9218
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17688 times.
17688 if(get_qr(qr_MELEEMAGICCOST))tempitem.flags |= item_flag6;
9219 17688 else tempitem.flags &= ~item_flag6;
9220 17688 }
9221 73472 }
9222
9223
2/2
✓ Branch 0 taken 48640 times.
✓ Branch 1 taken 73472 times.
122112 if( s_version < 43 )
9224 {
9225
2/2
✓ Branch 0 taken 73140 times.
✓ Branch 1 taken 332 times.
73472 if(tempitem.family == itype_whistle)
9226 {
9227
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 320 times.
332 if(get_qr(qr_WHIRLWINDMIRROR))tempitem.flags |= item_flag3;
9228 320 else tempitem.flags &= ~item_flag3;
9229 332 }
9230 73472 }
9231
9232
2/2
✓ Branch 0 taken 48640 times.
✓ Branch 1 taken 73472 times.
122112 if( s_version < 45 )
9233 {
9234
2/2
✓ Branch 0 taken 73185 times.
✓ Branch 1 taken 287 times.
73472 if(tempitem.family == itype_flippers)
9235 {
9236 287 tempitem.misc1 = 50; //Dive length, default 50 frames -V
9237 287 tempitem.misc2 = 30; //Dive cooldown, default 30 frames -V
9238 287 }
9239 73472 }
9240
9241
2/2
✓ Branch 0 taken 48640 times.
✓ Branch 1 taken 73472 times.
122112 if( s_version < 46 )
9242 {
9243
2/2
✓ Branch 0 taken 73188 times.
✓ Branch 1 taken 284 times.
73472 if(tempitem.family == itype_raft)
9244 {
9245 284 tempitem.misc1 = 1; //Rafting speed modifier; default 1. Negative slows, positive speeds.
9246 284 }
9247 73472 }
9248
2/2
✓ Branch 0 taken 48640 times.
✓ Branch 1 taken 73472 times.
122112 if ( s_version < 34 ) //! set the default counter for older quests.
9249 {
9250
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 73357 times.
73472 if ( (tempitem.flags & item_rupee_magic) )
9251 {
9252 115 tempitem.cost_counter[0] = 1;
9253 115 }
9254 else
9255 {
9256
2/2
✓ Branch 0 taken 44032 times.
✓ Branch 1 taken 29325 times.
73357 if(get_qr(qr_ENABLEMAGIC))
9257 44032 tempitem.cost_counter[0] = 4;
9258 else
9259 {
9260 29325 tempitem.cost_amount[0] = 0;
9261 29325 tempitem.cost_counter[0] = -1;
9262 }
9263 }
9264 73472 }
9265
9266
2/2
✓ Branch 0 taken 48640 times.
✓ Branch 1 taken 73472 times.
122112 if ( s_version < 35 ) //new Lens of Truth flags
9267 {
9268
2/2
✓ Branch 0 taken 73212 times.
✓ Branch 1 taken 260 times.
73472 if ( tempitem.family == itype_lens )
9269 {
9270
2/2
✓ Branch 0 taken 248 times.
✓ Branch 1 taken 12 times.
260 if ( get_qr(qr_RAFTLENS) )
9271 {
9272 12 tempitem.flags |= item_flag4;
9273 12 }
9274
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 167 times.
260 if ( get_qr(qr_LENSHINTS) )
9275 {
9276 167 tempitem.flags |= item_flag1;
9277 167 }
9278
2/2
✓ Branch 0 taken 244 times.
✓ Branch 1 taken 16 times.
260 if ( get_qr(qr_LENSSEESENEMIES) )
9279 {
9280 16 tempitem.flags |= item_flag5;
9281 16 }
9282 260 }
9283 73472 }
9284
2/2
✓ Branch 0 taken 48640 times.
✓ Branch 1 taken 73472 times.
122112 if ( s_version < 44 ) //InitD Labels and Sprite Script Data
9285 {
9286
2/2
✓ Branch 0 taken 587776 times.
✓ Branch 1 taken 73472 times.
661248 for ( int32_t q = 0; q < 8; q++ )
9287 {
9288 587776 sprintf(tempitem.initD_label[q],"InitD[%d]",q);
9289 587776 sprintf(tempitem.weapon_initD_label[q],"InitD[%d]",q);
9290 587776 sprintf(tempitem.sprite_initD_label[q],"InitD[%d]",q);
9291 587776 tempitem.sprite_initiald[q] = 0;
9292 587776 }
9293 73472 tempitem.sprite_script = 0;
9294 73472 }
9295
2/2
✓ Branch 0 taken 48640 times.
✓ Branch 1 taken 73472 times.
122112 if ( s_version < 47 ) //InitD Labels and Sprite Script Data
9296 {
9297 73472 tempitem.pickupflag = 0;
9298 73472 }
9299
9300
2/2
✓ Branch 0 taken 48640 times.
✓ Branch 1 taken 73472 times.
122112 if( s_version < 51 )
9301 {
9302
2/2
✓ Branch 0 taken 72862 times.
✓ Branch 1 taken 610 times.
73472 if( tempitem.family == itype_candle )
9303 {
9304 610 tempitem.misc4 = 50; //Step speed
9305 610 }
9306 73472 }
9307
9308
2/2
✓ Branch 0 taken 48640 times.
✓ Branch 1 taken 73472 times.
122112 if( s_version < 52 )
9309 {
9310
2/2
✓ Branch 0 taken 72599 times.
✓ Branch 1 taken 873 times.
73472 if( tempitem.family == itype_shield )
9311 873 tempitem.flags |= item_flag1; //'Block Front' flag
9312 73472 }
9313
2/2
✓ Branch 0 taken 48640 times.
✓ Branch 1 taken 73472 times.
122112 if(s_version < 53)
9314 {
9315
4/4
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 72042 times.
✓ Branch 2 taken 844 times.
✓ Branch 3 taken 286 times.
73472 switch(tempitem.family)
9316 {
9317 case itype_arrow:
9318 844 tempitem.cost_counter[1] = crARROWS;
9319 844 tempitem.cost_amount[1] = 1;
9320 844 break;
9321 case itype_bomb:
9322 300 tempitem.cost_counter[1] = crBOMBS;
9323 300 tempitem.cost_amount[1] = 1;
9324 300 break;
9325 case itype_sbomb:
9326 286 tempitem.cost_counter[1] = crSBOMBS;
9327 286 tempitem.cost_amount[1] = 1;
9328 286 break;
9329 default:
9330 72042 tempitem.cost_counter[1] = crNONE;
9331 72042 tempitem.cost_amount[1] = 0;
9332 72042 }
9333 73472 tempitem.magiccosttimer[1] = 0;
9334 73472 }
9335
2/2
✓ Branch 0 taken 45824 times.
✓ Branch 1 taken 76288 times.
122112 if( s_version < 54 )
9336 {
9337
2/2
✓ Branch 0 taken 75988 times.
✓ Branch 1 taken 300 times.
76288 if( tempitem.family == itype_flippers )
9338 300 tempitem.misc3 = INT_BTN_A; //'Block Front' flag
9339 76288 }
9340
2/2
✓ Branch 0 taken 45824 times.
✓ Branch 1 taken 76288 times.
122112 if(s_version < 55)
9341 {
9342
3/3
✓ Branch 0 taken 590 times.
✓ Branch 1 taken 590 times.
✓ Branch 2 taken 75108 times.
76288 switch(tempitem.family)
9343 {
9344 case itype_spinscroll:
9345 case itype_quakescroll:
9346 590 tempitem.usesound2 = WAV_ZN1CHARGE;
9347 590 break;
9348 case itype_spinscroll2:
9349 case itype_quakescroll2:
9350 590 tempitem.usesound2 = WAV_ZN1CHARGE2;
9351 590 break;
9352 }
9353 76288 }
9354
2/2
✓ Branch 0 taken 45824 times.
✓ Branch 1 taken 76288 times.
122112 if(s_version < 56)
9355 {
9356
4/4
✓ Branch 0 taken 75046 times.
✓ Branch 1 taken 295 times.
✓ Branch 2 taken 636 times.
✓ Branch 3 taken 311 times.
76288 switch(tempitem.family)
9357 {
9358 case itype_divinefire:
9359
2/2
✓ Branch 0 taken 284 times.
✓ Branch 1 taken 11 times.
295 SETFLAG(tempitem.flags, item_flag9, version < 0x255); //Strong Fire
9360
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 213 times.
295 SETFLAG(tempitem.flags, item_flag10, version < 0x250); //Magic Fire
9361 295 tempitem.flags |= item_flag11; //Divine Fire
9362 295 break;
9363 case itype_candle:
9364
2/2
✓ Branch 0 taken 317 times.
✓ Branch 1 taken 319 times.
636 SETFLAG(tempitem.flags, item_flag9, tempitem.fam_type > 1); //Strong Fire
9365 636 tempitem.flags &= ~item_flag10; //Magic Fire
9366 636 tempitem.flags &= ~item_flag11; //Divine Fire
9367 636 break;
9368 case itype_book:
9369 311 tempitem.flags |= item_flag9; //Strong Fire
9370 311 tempitem.flags |= item_flag10; //Magic Fire
9371 311 tempitem.flags &= ~item_flag11; //Divine Fire
9372 311 break;
9373 }
9374 76288 }
9375
2/2
✓ Branch 0 taken 32256 times.
✓ Branch 1 taken 89856 times.
122112 if (s_version < 61)
9376 {
9377
2/2
✓ Branch 0 taken 70901 times.
✓ Branch 1 taken 18955 times.
89856 switch (tempitem.family)
9378 {
9379 case itype_sword:
9380 18955 tempitem.usesound2 = WAV_BEAM;
9381 18955 break;
9382 }
9383 89856 }
9384
9385
9386
2/2
✓ Branch 0 taken 10988 times.
✓ Branch 1 taken 111124 times.
122112 if(tempitem.fam_type==0) // Always do this
9387 10988 tempitem.fam_type=1;
9388
9389 122112 itemsbuf[i] = tempitem;
9390 122112 }
9391
9392 477 return 0;
9393 478 }
9394
9395 static bool did_init_def_items = false;
9396 244090 void init_def_items()
9397 {
9398
2/2
✓ Branch 0 taken 243722 times.
✓ Branch 1 taken 368 times.
244090 if(did_init_def_items) return;
9399 368 did_init_def_items = true;
9400 368 default_items[3].cost_counter[1] = crBOMBS;
9401 368 default_items[13].cost_counter[1] = crARROWS;
9402 368 default_items[14].cost_counter[1] = crARROWS;
9403 368 default_items[48].cost_counter[1] = crSBOMBS;
9404 368 default_items[57].cost_counter[1] = crARROWS;
9405 244090 }
9406 244090 void reset_itembuf(itemdata *item, int32_t id)
9407 {
9408 244090 init_def_items();
9409
2/2
✓ Branch 0 taken 102491 times.
✓ Branch 1 taken 141599 times.
244090 if(id<iLast)
9410 {
9411 // Copy everything *EXCEPT* the tile, misc, cset, frames, speed, delay and ltm.
9412 141599 word tile = item->tile;
9413 141599 byte miscs = item->misc_flags, cset = item->csets, frames = item->frames, speed = item->speed, delay = item->delay;
9414 141599 int32_t ltm = item->ltm;
9415
9416 141599 *item = default_items[id];
9417 141599 item->tile = tile;
9418 141599 item->misc_flags = miscs;
9419 141599 item->csets = cset;
9420 141599 item->frames = frames;
9421 141599 item->speed = speed;
9422 141599 item->delay = delay;
9423 141599 item->ltm = ltm;
9424 141599 }
9425 244090 }
9426
9427 100864 void reset_itemname(int32_t id)
9428 {
9429 100864 sprintf(item_string[id],"zz%03d",id);
9430
9431
2/2
✓ Branch 0 taken 44522 times.
✓ Branch 1 taken 56342 times.
100864 if(id < iLast)
9432 56342 strcpy(item_string[id],old_item_string[id]);
9433 100864 }
9434
9435 478 int32_t readweapons(PACKFILE *f, zquestheader *Header)
9436 {
9437
2/2
✓ Branch 0 taken 454 times.
✓ Branch 1 taken 24 times.
478 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_weapons);
9438
9439 478 word weapons_to_read=MAXWPNS;
9440 int32_t dummy;
9441 byte padding;
9442 wpndata tempweapon;
9443 478 word s_version=0;
9444
9445
9446
2/2
✓ Branch 0 taken 472 times.
✓ Branch 1 taken 6 times.
478 if(Header->zelda_version < 0x186)
9447 {
9448 6 weapons_to_read=64;
9449 6 }
9450
9451
2/2
✓ Branch 0 taken 472 times.
✓ Branch 1 taken 6 times.
478 if(Header->zelda_version < 0x185)
9452 {
9453 6 weapons_to_read=32;
9454 6 }
9455
9456
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 454 times.
478 if(Header->zelda_version > 0x192)
9457 {
9458 454 weapons_to_read=0;
9459
9460 //section version info
9461
1/2
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
454 if(!p_igetw(&s_version,f))
9462 {
9463 return qe_invalid;
9464 }
9465
9466 454 FFCore.quest_format[vWeaponSprites] = s_version;
9467
9468
1/2
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
454 if(!read_deprecated_section_cversion(f))
9469 {
9470 return qe_invalid;
9471 }
9472
9473 //section size
9474
1/2
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
454 if(!p_igetl(&dummy,f))
9475 {
9476 return qe_invalid;
9477 }
9478
9479 //finally... section data
9480
1/2
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
454 if(!p_igetw(&weapons_to_read,f))
9481 {
9482 return qe_invalid;
9483 }
9484
9485
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 454 times.
454 if (weapons_to_read > MAXWPNS)
9486 {
9487 return qe_invalid;
9488 }
9489 454 }
9490
9491
2/2
✓ Branch 0 taken 395 times.
✓ Branch 1 taken 83 times.
478 if(s_version>2)
9492 {
9493
2/2
✓ Branch 0 taken 101120 times.
✓ Branch 1 taken 395 times.
101515 for(int32_t i=0; i<weapons_to_read; i++)
9494 {
9495 char tempname[64];
9496
9497
1/2
✓ Branch 0 taken 101120 times.
✗ Branch 1 not taken.
101120 if(!pfread(tempname, 64, f))
9498 {
9499 return qe_invalid;
9500 }
9501
9502 101120 weapon_string[i][0] = '\0';
9503 101120 strncat(weapon_string[i], tempname, 64 - 1);
9504 101120 }
9505
9506
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 if(s_version<4)
9507 {
9508 strcpy(weapon_string[iwHover],old_weapon_string[iwHover]);
9509 strcpy(weapon_string[wFIREMAGIC],old_weapon_string[wFIREMAGIC]);
9510 }
9511
9512
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 if(s_version<5)
9513 {
9514 strcpy(weapon_string[iwQuarterHearts],old_weapon_string[iwQuarterHearts]);
9515 }
9516
9517 /*
9518 if (s_version<6)
9519 {
9520 strcpy(weapon_string[iwSideRaft],old_weapon_string[iwSideRaft]);
9521 strcpy(weapon_string[iwSideLadder],old_weapon_string[iwSideLadder]);
9522 }
9523 */
9524 395 }
9525
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 82 times.
83 else if (!should_skip)
9526 {
9527
2/2
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 82 times.
21074 for(int32_t i=0; i<MAXWPNS; i++)
9528 20992 reset_weaponname(i);
9529 82 }
9530
9531
2/2
✓ Branch 0 taken 109932 times.
✓ Branch 1 taken 478 times.
110410 for(int32_t i=0; i<weapons_to_read; i++)
9532 {
9533 109932 word oldtile = 0;
9534
2/2
✓ Branch 0 taken 47360 times.
✓ Branch 1 taken 62572 times.
109932 if (s_version < 8)
9535 {
9536
1/2
✓ Branch 0 taken 62572 times.
✗ Branch 1 not taken.
62572 if (!p_igetw(&oldtile, f))
9537 return qe_invalid;
9538 62572 }
9539
9540
1/2
✓ Branch 0 taken 109932 times.
✗ Branch 1 not taken.
109932 if(!p_getc(&tempweapon.misc,f))
9541 {
9542 return qe_invalid;
9543 }
9544
9545
1/2
✓ Branch 0 taken 109932 times.
✗ Branch 1 not taken.
109932 if(!p_getc(&tempweapon.csets,f))
9546 {
9547 return qe_invalid;
9548 }
9549
9550
1/2
✓ Branch 0 taken 109932 times.
✗ Branch 1 not taken.
109932 if(!p_getc(&tempweapon.frames,f))
9551 {
9552 return qe_invalid;
9553 }
9554
9555
1/2
✓ Branch 0 taken 109932 times.
✗ Branch 1 not taken.
109932 if(!p_getc(&tempweapon.speed,f))
9556 {
9557 return qe_invalid;
9558 }
9559
9560
1/2
✓ Branch 0 taken 109932 times.
✗ Branch 1 not taken.
109932 if(!p_getc(&tempweapon.type,f))
9561 {
9562 return qe_invalid;
9563 }
9564
9565
2/2
✓ Branch 0 taken 61292 times.
✓ Branch 1 taken 48640 times.
109932 if ( s_version >= 7 )
9566 {
9567
1/2
✓ Branch 0 taken 48640 times.
✗ Branch 1 not taken.
48640 if(!p_igetw(&tempweapon.script,f))
9568 {
9569 return qe_invalid;
9570 }
9571
1/2
✓ Branch 0 taken 48640 times.
✗ Branch 1 not taken.
48640 if(!p_igetl(&tempweapon.tile,f))
9572 {
9573 return qe_invalid;
9574 }
9575 48640 }
9576
2/2
✓ Branch 0 taken 48640 times.
✓ Branch 1 taken 61292 times.
109932 if ( s_version < 7 )
9577 {
9578 61292 tempweapon.tile = oldtile;
9579 61292 }
9580
9581
2/2
✓ Branch 0 taken 105132 times.
✓ Branch 1 taken 4800 times.
109932 if(Header->zelda_version < 0x193)
9582 {
9583
1/2
✓ Branch 0 taken 4800 times.
✗ Branch 1 not taken.
4800 if(!p_getc(&padding,f))
9584 {
9585 return qe_invalid;
9586 }
9587 4800 }
9588
9589
2/2
✓ Branch 0 taken 101120 times.
✓ Branch 1 taken 8812 times.
109932 if(s_version < 6)
9590 {
9591
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 8794 times.
8812 if(i==ewFIRETRAIL)
9592 {
9593 18 tempweapon.misc |= WF_BEHIND;
9594 18 }
9595 else
9596 8794 tempweapon.misc &= ~WF_BEHIND;
9597 8812 }
9598
9599
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 109676 times.
109932 if (!should_skip)
9600 109676 memcpy(&wpnsbuf[i], &tempweapon, sizeof(tempweapon));
9601 109932 }
9602
9603
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 477 times.
478 if (should_skip)
9604 1 return 0;
9605
9606
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 395 times.
477 if(s_version<2)
9607 {
9608 82 wpnsbuf[wSBOOM]=wpnsbuf[wBOOM];
9609 82 }
9610
9611
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 395 times.
477 if(s_version<5)
9612 {
9613 82 wpnsbuf[iwQuarterHearts].tile=1;
9614 82 wpnsbuf[iwQuarterHearts].csets=1;
9615 82 }
9616
9617
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 477 times.
477 if(Header->zelda_version < 0x176)
9618 {
9619 wpnsbuf[iwSpawn] = *((wpndata*)(itemsbuf + iMisc1));
9620 wpnsbuf[iwDeath] = *((wpndata*)(itemsbuf + iMisc2));
9621 memset(&itemsbuf[iMisc1],0,sizeof(itemdata));
9622 memset(&itemsbuf[iMisc2],0,sizeof(itemdata));
9623 }
9624
9625
3/4
✓ Branch 0 taken 459 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
482 if((Header->zelda_version < 0x192)||
9626
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 454 times.
459 ((Header->zelda_version == 0x192)&&(Header->build<129)))
9627 {
9628 18 wpnsbuf[wHSCHAIN_V] = wpnsbuf[wHSCHAIN_H];
9629 18 }
9630
9631
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 454 times.
477 if((Header->zelda_version < 0x210))
9632 {
9633 23 wpnsbuf[wLSHEAD] = wpnsbuf[wHSHEAD];
9634 23 wpnsbuf[wLSCHAIN_H] = wpnsbuf[wHSCHAIN_H];
9635 23 wpnsbuf[wLSHANDLE] = wpnsbuf[wHSHANDLE];
9636 23 wpnsbuf[wLSCHAIN_V] = wpnsbuf[wHSCHAIN_V];
9637 23 }
9638
9639 477 return 0;
9640 478 }
9641
9642 223249 static void guy_update_firesfx(guydata& tempguy)
9643 {
9644 223249 tempguy.firesfx = 0;
9645
2/2
✓ Branch 0 taken 6431 times.
✓ Branch 1 taken 216818 times.
223249 if (tempguy.family == eeWIZZ)
9646 {
9647
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 973 times.
✓ Branch 2 taken 3931 times.
✓ Branch 3 taken 827 times.
✓ Branch 4 taken 700 times.
6431 switch (tempguy.attributes[1])
9648 {
9649 case 0: // normal weapon
9650 3931 tempguy.firesfx = WAV_WAND;
9651 3931 break;
9652 case 1: // 8 shots
9653
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 745 times.
827 if (get_qr(qr_8WAY_SHOT_SFX_DEP)) tempguy.firesfx = WAV_FIRE;
9654 else
9655 {
9656
3/8
✓ Branch 0 taken 642 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 87 times.
✓ Branch 3 taken 16 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
745 switch (tempguy.weapon)
9657 {
9658 case ewFireTrail:
9659 case ewFlame:
9660 case ewFlame2Trail:
9661 case ewFlame2:
9662 642 tempguy.firesfx = WAV_FIRE;
9663 642 break;
9664 case ewWind:
9665 case ewMagic:
9666 87 tempguy.firesfx = WAV_WAND;
9667 87 break;
9668 case ewIce:
9669 tempguy.firesfx = WAV_ZN1ICE;
9670 break;
9671 case ewRock:
9672 tempguy.firesfx = WAV_ZN1ROCK;
9673 break;
9674 case ewFireball2:
9675 case ewFireball:
9676 16 tempguy.firesfx = WAV_ZN1FIREBALL;
9677 16 break;
9678 case ewBrang:
9679 tempguy.firesfx = WAV_BRANG;
9680 break;
9681 case ewBomb:case ewSBomb: case ewLitBomb:case ewLitSBomb:
9682 tempguy.firesfx = WAV_BOMB;
9683 break;
9684 default:
9685 tempguy.firesfx = 0;
9686 break;
9687 }
9688 745 break;
9689 }
9690 case 2: // Summon
9691 1055 tempguy.firesfx = WAV_FIRE;
9692 1055 break;
9693 case 3: // Summon Layer
9694 700 tempguy.firesfx = get_qr(qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE;
9695 700 break;
9696 }
9697 6431 }
9698 else
9699 {
9700
6/6
✓ Branch 0 taken 164079 times.
✓ Branch 1 taken 52739 times.
✓ Branch 2 taken 41915 times.
✓ Branch 3 taken 205994 times.
✓ Branch 4 taken 47329 times.
✓ Branch 5 taken 47325 times.
216818 if ((tempguy.family == eeWALK || tempguy.family == eePROJECTILE) && (tempguy.attributes[0] == e1tSUMMON || tempguy.attributes[0] == e1tSUMMONLAYER))
9701 {
9702 94654 tempguy.firesfx = get_qr(qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE;
9703 94654 }
9704 else
9705 {
9706
7/8
✓ Branch 0 taken 9619 times.
✓ Branch 1 taken 2357 times.
✓ Branch 2 taken 1806 times.
✓ Branch 3 taken 12826 times.
✓ Branch 4 taken 173157 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3961 times.
✓ Branch 7 taken 2268 times.
205994 switch (tempguy.weapon)
9707 {
9708 case ewFireTrail:
9709 case ewFlame:
9710 case ewFlame2Trail:
9711 case ewFlame2:
9712 9619 tempguy.firesfx = WAV_FIRE;
9713 9619 break;
9714 case ewWind:
9715 case ewMagic:
9716 1806 tempguy.firesfx = WAV_WAND;
9717 1806 break;
9718 case ewIce:
9719 tempguy.firesfx = WAV_ZN1ICE;
9720 break;
9721 case ewRock:
9722 3961 tempguy.firesfx = WAV_ZN1ROCK;
9723 3961 break;
9724 case ewFireball2:
9725 case ewFireball:
9726 12826 tempguy.firesfx = WAV_ZN1FIREBALL;
9727 12826 break;
9728 case ewBrang:
9729 2268 tempguy.firesfx = WAV_BRANG;
9730 2268 break;
9731 case ewBomb:case ewSBomb: case ewLitBomb:case ewLitSBomb:
9732 2357 tempguy.firesfx = WAV_BOMB;
9733 2357 break;
9734 default:
9735 173157 tempguy.firesfx = 0;
9736 173157 break;
9737 }
9738 }
9739 }
9740 212429 }
9741
9742 212429 static void guy_update_weaponflags(guydata& tempguy)
9743 {
9744 212429 tempguy.wunblockable = 0;
9745 212429 tempguy.wmoveflags = move_none;
9746
4/4
✓ Branch 0 taken 205901 times.
✓ Branch 1 taken 6528 times.
✓ Branch 2 taken 3002 times.
✓ Branch 3 taken 202899 times.
212429 if (tempguy.weapon == ewFlame || tempguy.weapon == ewFireTrail)
9747 9530 tempguy.wmoveflags |= (move_obeys_grav | move_can_pitfall);
9748 212429 tempguy.weapoverrideFLAGS = 0;
9749 212429 tempguy.weap_hxofs = 0;
9750 212429 tempguy.weap_hyofs = 0;
9751 212429 tempguy.weap_hxsz = 0;
9752 212429 tempguy.weap_hysz = 0;
9753 212429 tempguy.weap_hzsz = 0;
9754 212429 tempguy.weap_xofs = 0;
9755 212429 tempguy.weap_yofs = 0;
9756 212429 tempguy.weap_tilew = 0;
9757 212429 tempguy.weap_tileh = 0;
9758
5/5
✓ Branch 0 taken 2507 times.
✓ Branch 1 taken 171179 times.
✓ Branch 2 taken 18517 times.
✓ Branch 3 taken 12842 times.
✓ Branch 4 taken 7384 times.
212429 switch (tempguy.weapon)
9759 {
9760 case ewFireball: case ewFireball2:
9761 12842 tempguy.wstep = 175;
9762 12842 break;
9763 case ewSword: case ewLitBomb: case ewLitSBomb:
9764 case ewRock: case ewMagic: case ewWind:
9765 18517 tempguy.wstep = 300;
9766 18517 break;
9767 case ewArrow:
9768 2507 tempguy.wstep = 200;
9769 2507 break;
9770 case ewFlame: case ewFlame2:
9771 7384 tempguy.wstep = 100;
9772 7384 break;
9773 default:
9774 171179 tempguy.wstep = 0;
9775 171179 break;
9776 }
9777
2/2
✓ Branch 0 taken 1062145 times.
✓ Branch 1 taken 212429 times.
1274574 for (int q = 0; q < WPNSPR_MAX; ++q)
9778 {
9779 1062145 tempguy.burnsprs[q] = 0;
9780 1062145 tempguy.light_rads[q] = 0;
9781 1062145 }
9782 212429 }
9783
9784 212429 static void guy_update_weaponspecialsfx(guydata& tempguy)
9785 {
9786
3/3
✓ Branch 0 taken 2268 times.
✓ Branch 1 taken 207749 times.
✓ Branch 2 taken 2412 times.
212429 switch (tempguy.weapon)
9787 {
9788 case ewBrang:
9789 2268 tempguy.specialsfx = WAV_BRANG;
9790 2268 break;
9791 case ewBomb: case ewSBomb: case ewLitBomb:case ewLitSBomb:
9792 2412 tempguy.specialsfx = WAV_BOMB;
9793 2412 break;
9794 default:
9795 207749 tempguy.specialsfx = 0;
9796 207749 break;
9797 }
9798 212429 }
9799
9800 477 void init_guys(int32_t guyversion)
9801 {
9802
2/2
✓ Branch 0 taken 244224 times.
✓ Branch 1 taken 477 times.
244701 for(int32_t i=0; i<MAXGUYS; i++)
9803 {
9804 244224 guysbuf[i] = default_guys[0];
9805 244224 }
9806
9807
2/2
✓ Branch 0 taken 84429 times.
✓ Branch 1 taken 477 times.
84906 for(int32_t i=0; i<OLDMAXGUYS; i++)
9808 {
9809 84429 guysbuf[i] = default_guys[i];
9810
2/2
✓ Branch 0 taken 83475 times.
✓ Branch 1 taken 954 times.
84429 guysbuf[i].spr_shadow = (guysbuf[i].family==eeROCK && guysbuf[i].attributes[9] == 1) ? iwLargeShadow : iwShadow;
9811 84429 guysbuf[i].spr_death = iwDeath;
9812 84429 guysbuf[i].spr_spawn = iwSpawn;
9813 // Patra fix: 2.10 BSPatras used spDIG. 2.50 Patras use CSet 7.
9814
4/4
✓ Branch 0 taken 14514 times.
✓ Branch 1 taken 69915 times.
✓ Branch 2 taken 14432 times.
✓ Branch 3 taken 82 times.
84429 if(guyversion<=3 && i==ePATRABS)
9815 {
9816 82 guysbuf[i].bosspal=spDIG;
9817 82 guysbuf[i].cset=14;
9818 82 guysbuf[i].attributes[8] = 14;
9819 82 }
9820
9821
2/2
✓ Branch 0 taken 69915 times.
✓ Branch 1 taken 14514 times.
84429 if(guyversion<=3)
9822 {
9823 // Rope/Ghini Flash rules
9824
2/2
✓ Branch 0 taken 4071 times.
✓ Branch 1 taken 10443 times.
14514 if(get_bit(deprecated_rules, qr_NOROPE2FLASH_DEP))
9825 {
9826
2/2
✓ Branch 0 taken 10384 times.
✓ Branch 1 taken 59 times.
10443 if(i==eROPE2)
9827 {
9828 59 guysbuf[i].flags &= ~guy_flashing;
9829 59 }
9830 10443 }
9831
9832
2/2
✓ Branch 0 taken 12390 times.
✓ Branch 1 taken 2124 times.
14514 if(get_bit(deprecated_rules, qr_NOBUBBLEFLASH_DEP))
9833 {
9834
12/12
✓ Branch 0 taken 2112 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 2100 times.
✓ Branch 3 taken 12 times.
✓ Branch 4 taken 2088 times.
✓ Branch 5 taken 12 times.
✓ Branch 6 taken 2076 times.
✓ Branch 7 taken 12 times.
✓ Branch 8 taken 2064 times.
✓ Branch 9 taken 12 times.
✓ Branch 10 taken 12 times.
✓ Branch 11 taken 2052 times.
2124 if(i==eBUBBLEST || i==eBUBBLESP || i==eBUBBLESR || i==eBUBBLEIT || i==eBUBBLEIP || i==eBUBBLEIR)
9835 {
9836 72 guysbuf[i].flags &= ~guy_flashing;
9837 72 }
9838 2124 }
9839
9840
2/2
✓ Branch 0 taken 14432 times.
✓ Branch 1 taken 82 times.
14514 if(i==eGHINI2)
9841 {
9842
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 4 times.
82 if(get_bit(deprecated_rules, qr_GHINI2BLINK_DEP))
9843 {
9844 4 guysbuf[i].flags |= guy_blinking;
9845 4 }
9846
9847
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 38 times.
82 if(get_bit(deprecated_rules, qr_PHANTOMGHINI2_DEP))
9848 {
9849 38 guysbuf[i].flags |= guy_transparent;
9850 38 }
9851 82 }
9852
9853
4/4
✓ Branch 0 taken 14432 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 14350 times.
14514 if (i == eDIG1 || i == eDIG3)
9854 {
9855 164 guysbuf[i].flags |= guy_ignore_kill_all;
9856 164 }
9857 14514 }
9858
9859 // Darknut fix
9860
10/10
✓ Branch 0 taken 83952 times.
✓ Branch 1 taken 477 times.
✓ Branch 2 taken 83475 times.
✓ Branch 3 taken 477 times.
✓ Branch 4 taken 82998 times.
✓ Branch 5 taken 477 times.
✓ Branch 6 taken 82521 times.
✓ Branch 7 taken 477 times.
✓ Branch 8 taken 477 times.
✓ Branch 9 taken 82044 times.
84429 if(i==eDKNUT1 || i==eDKNUT2 || i==eDKNUT3 || i==eDKNUT4 || i==eDKNUT5)
9861 {
9862
2/2
✓ Branch 0 taken 1980 times.
✓ Branch 1 taken 405 times.
2385 if(get_qr(qr_NEWENEMYTILES))
9863 {
9864 1980 guysbuf[i].s_tile=guysbuf[i].e_tile+120;
9865 1980 guysbuf[i].s_width=guysbuf[i].e_width;
9866 1980 guysbuf[i].s_height=guysbuf[i].e_height;
9867 1980 }
9868 405 else guysbuf[i].s_tile=860;
9869
9870
2/2
✓ Branch 0 taken 320 times.
✓ Branch 1 taken 2065 times.
2385 if(!get_bit(deprecated_rules,qr_BRKBLSHLDS_DEP))
9871 2065 guysbuf[i].flags &= ~guy_bkshield;
9872 else
9873 320 guysbuf[i].flags |= guy_bkshield;
9874 2385 }
9875
9876
4/4
✓ Branch 0 taken 83952 times.
✓ Branch 1 taken 477 times.
✓ Branch 2 taken 84379 times.
✓ Branch 3 taken 50 times.
84429 if((i==eGELTRIB || i==eFGELTRIB) && get_bit(deprecated_rules,qr_OLDTRIBBLES_DEP))
9877 {
9878 50 guysbuf[i].attributes[2] = (i == eFGELTRIB ? eFZOL : eZOL);
9879 50 }
9880
9881 84429 guy_update_firesfx(guysbuf[i]);
9882 84429 guy_update_weaponflags(guysbuf[i]);
9883 84429 guy_update_weaponspecialsfx(guysbuf[i]);
9884 84429 }
9885 477 }
9886
9887 20992 void reset_weaponname(int32_t i)
9888 {
9889
2/2
✓ Branch 0 taken 7216 times.
✓ Branch 1 taken 13776 times.
20992 if(i<wLast)
9890 {
9891 7216 strcpy(weapon_string[i],old_weapon_string[i]);
9892 7216 }
9893 else
9894 13776 sprintf(weapon_string[i],"zz%03d",i);
9895 20992 }
9896
9897 477 void init_item_drop_sets()
9898 {
9899
2/2
✓ Branch 0 taken 122112 times.
✓ Branch 1 taken 477 times.
122589 for(int32_t i=0; i<MAXITEMDROPSETS; i++)
9900 {
9901 // item_drop_sets[i] = default_item_drop_sets[0];
9902 122112 memset(&item_drop_sets[i], 0, sizeof(item_drop_object));
9903 122112 }
9904
9905
2/2
✓ Branch 0 taken 6201 times.
✓ Branch 1 taken 477 times.
6678 for(int32_t i=0; i<isMAX; i++)
9906 {
9907 6201 item_drop_sets[i] = default_item_drop_sets[i];
9908
9909 // Deprecated: qr_NOCLOCKS and qr_ALLOW10RUPEEDROPS
9910
2/2
✓ Branch 0 taken 62010 times.
✓ Branch 1 taken 6201 times.
68211 for(int32_t j=0; j<10; ++j)
9911 {
9912 62010 int32_t it = item_drop_sets[i].item[j];
9913
9914
3/4
✓ Branch 0 taken 43608 times.
✓ Branch 1 taken 18402 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2814 times.
62010 if((itemsbuf[it].family == itype_rupee && ((itemsbuf[it].amount)&0xFFF) == 10)
9915
2/2
✓ Branch 0 taken 2814 times.
✓ Branch 1 taken 40794 times.
43608 && !get_bit(deprecated_rules, qr_ALLOW10RUPEEDROPS_DEP))
9916 {
9917 2814 item_drop_sets[i].chance[j+1]=0;
9918 2814 }
9919
4/4
✓ Branch 0 taken 1908 times.
✓ Branch 1 taken 57288 times.
✓ Branch 2 taken 144 times.
✓ Branch 3 taken 1764 times.
59196 else if(itemsbuf[it].family == itype_clock && get_bit(deprecated_rules, qr_NOCLOCKS_DEP))
9920 {
9921 144 item_drop_sets[i].chance[j+1]=0;
9922 144 }
9923
9924 // From Sept 2007 to Dec 2008, non-gameplay items were prohibited.
9925
2/2
✓ Branch 0 taken 61986 times.
✓ Branch 1 taken 24 times.
62010 if(itemsbuf[it].family == itype_misc)
9926 {
9927 // If a non-gameplay item was selected, then item drop was aborted.
9928 // Reflect this by increasing the 'Nothing' chance accordingly.
9929 24 item_drop_sets[i].chance[0]+=item_drop_sets[i].chance[j+1];
9930 24 item_drop_sets[i].chance[j+1]=0;
9931 24 }
9932 62010 }
9933 6201 }
9934 477 }
9935
9936 477 void init_favorites()
9937 {
9938
2/2
✓ Branch 0 taken 601020 times.
✓ Branch 1 taken 477 times.
601497 for(int32_t i=0; i<MAXFAVORITECOMBOS; i++)
9939 {
9940 601020 favorite_combos[i]=-1;
9941 601020 }
9942 477 }
9943
9944 const char *ctype_name[cMAX]=
9945 {
9946 "cNONE", "cSTAIR", "cCAVE", "cWATER", "cARMOS", "cGRAVE", "cDOCK",
9947 "cUNDEF", "cPUSH_WAIT", "cPUSH_HEAVY", "cPUSH_HW", "cL_STATUE", "cR_STATUE",
9948 "cWALKSLOW", "cCVUP", "cCVDOWN", "cCVLEFT", "cCVRIGHT", "cSWIMWARP", "cDIVEWARP",
9949 "cLADDERHOOKSHOT", "cTRIGNOFLAG", "cTRIGFLAG", "cZELDA", "cSLASH", "cSLASHITEM",
9950 "cPUSH_HEAVY2", "cPUSH_HW2", "cPOUND", "cHSGRAB", "cHSBRIDGE", "cDAMAGE1",
9951 "cDAMAGE2", "cDAMAGE3", "cDAMAGE4", "cC_STATUE", "cTRAP_H", "cTRAP_V", "cTRAP_4",
9952 "cTRAP_LR", "cTRAP_UD", "cPIT", "cHOOKSHOTONLY", "cOVERHEAD", "cNOFLYZONE", "cMIRROR",
9953 "cMIRRORSLASH", "cMIRRORBACKSLASH", "cMAGICPRISM", "cMAGICPRISM4",
9954 "cMAGICSPONGE", "cCAVE2", "cEYEBALL_A", "cEYEBALL_B", "cNOJUMPZONE", "cBUSH",
9955 "cFLOWERS", "cTALLGRASS", "cSHALLOWWATER", "cLOCKBLOCK", "cLOCKBLOCK2",
9956 "cBOSSLOCKBLOCK", "cBOSSLOCKBLOCK2", "cLADDERONLY", "cBSGRAVE",
9957 "cCHEST", "cCHEST2", "cLOCKEDCHEST", "cLOCKEDCHEST2", "cBOSSCHEST", "cBOSSCHEST2",
9958 "cRESET", "cSAVE", "cSAVE2", "cCAVEB", "cCAVEC", "cCAVED",
9959 "cSTAIRB", "cSTAIRC", "cSTAIRD", "cPITB", "cPITC", "cPITD",
9960 "cCAVE2B", "cCAVE2C", "cCAVE2D", "cSWIMWARPB", "cSWIMWARPC", "cSWIMWARPD",
9961 "cDIVEWARPB", "cDIVEWARPC", "cDIVEWARPD", "cSTAIRR", "cPITR",
9962 "cAWARPA", "cAWARPB", "cAWARPC", "cAWARPD", "cAWARPR",
9963 "cSWARPA", "cSWARPB", "cSWARPC", "cSWARPD", "cSWARPR", "cSTRIGNOFLAG", "cSTRIGFLAG",
9964 "cSTEP", "cSTEPSAME", "cSTEPALL", "cSTEPCOPY", "cNOENEMY", "cBLOCKARROW1", "cBLOCKARROW2",
9965 "cBLOCKARROW3", "cBLOCKBRANG1", "cBLOCKBRANG2", "cBLOCKBRANG3", "cBLOCKSBEAM", "cBLOCKALL",
9966 "cBLOCKFIREBALL", "cDAMAGE5", "cDAMAGE6", "cDAMAGE7", "cCHANGE", "cSPINTILE1", "cSPINTILE2",
9967 "cSCREENFREEZE", "cSCREENFREEZEFF", "cNOGROUNDENEMY", "cSLASHNEXT", "cSLASHNEXTITEM", "cBUSHNEXT"
9968 "cSLASHTOUCHY", "cSLASHITEMTOUCHY", "cBUSHTOUCHY", "cFLOWERSTOUCHY", "cTALLGRASSTOUCHY",
9969 "cSLASHNEXTTOUCHY", "cSLASHNEXTITEMTOUCHY", "cBUSHNEXTTOUCHY", "cEYEBALL_4", "cTALLGRASSNEXT",
9970 "cSCRIPT1", "cSCRIPT2", "cSCRIPT3", "cSCRIPT4", "cSCRIPT5",
9971 "cSCRIPT6", "cSCRIPT7", "cSCRIPT8", "cSCRIPT9", "cSCRIPT10",
9972 "cSCRIPT11", "cSCRIPT12", "cSCRIPT13", "cSCRIPT14", "cSCRIPT15",
9973 "cSCRIPT16", "cSCRIPT17", "cSCRIPT18", "cSCRIPT19", "cSCRIPT20"
9974
9975 };
9976
9977 769 int32_t init_combo_classes()
9978 {
9979
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 769 times.
769 zinfo* zi = (load_tmp_zi ? load_tmp_zi : &ZI);
9980
2/2
✓ Branch 0 taken 140727 times.
✓ Branch 1 taken 769 times.
141496 for(int32_t i=0; i<cMAX; i++)
9981 {
9982 140727 combo_class_buf[i] = default_combo_classes[i];
9983
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140727 times.
140727 if ( char const* nm = zi->getComboTypeName(i) )
9984 {
9985 140727 size_t len = strlen(nm);
9986
2/2
✓ Branch 0 taken 9006528 times.
✓ Branch 1 taken 140727 times.
9147255 for ( size_t q = 0; q < 64; q++ )
9987 {
9988
2/2
✓ Branch 0 taken 2061689 times.
✓ Branch 1 taken 6944839 times.
9006528 combo_class_buf[i].name[q] = (q<len ? nm[q] : 0);
9989 9006528 }
9990 140727 }
9991 140727 }
9992
9993 769 return 0;
9994 }
9995
9996 310 int32_t readherosprites2(PACKFILE *f, int32_t v_herosprites)
9997 {
9998
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 264 times.
310 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_herosprites);
9999
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 310 times.
310 if (should_skip) return 0;
10000
10001
1/2
✓ Branch 0 taken 310 times.
✗ Branch 1 not taken.
310 assert(v_herosprites < 6);
10002
10003 310 zinit.hero_swim_speed=67; //default
10004 310 setupherotiles(zinit.heroAnimationStyle);
10005 310 setupherodefenses();
10006 310 setupherooffsets();
10007
10008
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 205 times.
310 if(v_herosprites>=0)
10009 {
10010 word tile, tile2;
10011 byte flip, extend, dummy_byte;
10012
10013
2/2
✓ Branch 0 taken 820 times.
✓ Branch 1 taken 205 times.
1025 for(int32_t i=0; i<4; i++)
10014 {
10015
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_igetw(&tile,f))
10016 {
10017 return qe_invalid;
10018 }
10019
10020
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_getc(&flip,f))
10021 {
10022 return qe_invalid;
10023 }
10024
10025
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_getc(&extend,f))
10026 {
10027 return qe_invalid;
10028 }
10029
10030 820 walkspr[i][spr_tile]=(int32_t)tile;
10031 820 walkspr[i][spr_flip]=(int32_t)flip;
10032 820 walkspr[i][spr_extend]=(int32_t)extend;
10033 820 }
10034
10035
2/2
✓ Branch 0 taken 820 times.
✓ Branch 1 taken 205 times.
1025 for(int32_t i=0; i<4; i++)
10036 {
10037
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_igetw(&tile,f))
10038 {
10039 return qe_invalid;
10040 }
10041
10042
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_getc(&flip,f))
10043 {
10044 return qe_invalid;
10045 }
10046
10047
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_getc(&extend,f))
10048 {
10049 return qe_invalid;
10050 }
10051
10052 820 stabspr[i][spr_tile]=(int32_t)tile;
10053 820 stabspr[i][spr_flip]=(int32_t)flip;
10054 820 stabspr[i][spr_extend]=(int32_t)extend;
10055 820 }
10056
10057
2/2
✓ Branch 0 taken 820 times.
✓ Branch 1 taken 205 times.
1025 for(int32_t i=0; i<4; i++)
10058 {
10059
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_igetw(&tile,f))
10060 {
10061 return qe_invalid;
10062 }
10063
10064
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_getc(&flip,f))
10065 {
10066 return qe_invalid;
10067 }
10068
10069
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_getc(&extend,f))
10070 {
10071 return qe_invalid;
10072 }
10073
10074 820 slashspr[i][spr_tile]=(int32_t)tile;
10075 820 slashspr[i][spr_flip]=(int32_t)flip;
10076 820 slashspr[i][spr_extend]=(int32_t)extend;
10077 820 }
10078
10079
2/2
✓ Branch 0 taken 820 times.
✓ Branch 1 taken 205 times.
1025 for(int32_t i=0; i<4; i++)
10080 {
10081
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_igetw(&tile,f))
10082 {
10083 return qe_invalid;
10084 }
10085
10086
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_getc(&flip,f))
10087 {
10088 return qe_invalid;
10089 }
10090
10091
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_getc(&extend,f))
10092 {
10093 return qe_invalid;
10094 }
10095
10096 820 floatspr[i][spr_tile]=(int32_t)tile;
10097 820 floatspr[i][spr_flip]=(int32_t)flip;
10098 820 floatspr[i][spr_extend]=(int32_t)extend;
10099 820 }
10100
10101
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 205 times.
205 if(v_herosprites>1)
10102 {
10103
2/2
✓ Branch 0 taken 820 times.
✓ Branch 1 taken 205 times.
1025 for(int32_t i=0; i<4; i++)
10104 {
10105
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_igetw(&tile,f))
10106 {
10107 return qe_invalid;
10108 }
10109
10110
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_getc(&flip,f))
10111 {
10112 return qe_invalid;
10113 }
10114
10115
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_getc(&extend,f))
10116 {
10117 return qe_invalid;
10118 }
10119
10120 820 swimspr[i][spr_tile]=(int32_t)tile;
10121 820 swimspr[i][spr_flip]=(int32_t)flip;
10122 820 swimspr[i][spr_extend]=(int32_t)extend;
10123 820 }
10124 205 }
10125
10126
2/2
✓ Branch 0 taken 820 times.
✓ Branch 1 taken 205 times.
1025 for(int32_t i=0; i<4; i++)
10127 {
10128
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_igetw(&tile,f))
10129 {
10130 return qe_invalid;
10131 }
10132
10133
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_getc(&flip,f))
10134 {
10135 return qe_invalid;
10136 }
10137
10138
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_getc(&extend,f))
10139 {
10140 return qe_invalid;
10141 }
10142
10143 820 divespr[i][spr_tile]=(int32_t)tile;
10144 820 divespr[i][spr_flip]=(int32_t)flip;
10145 820 divespr[i][spr_extend]=(int32_t)extend;
10146 820 }
10147
10148
2/2
✓ Branch 0 taken 820 times.
✓ Branch 1 taken 205 times.
1025 for(int32_t i=0; i<4; i++)
10149 {
10150
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_igetw(&tile,f))
10151 {
10152 return qe_invalid;
10153 }
10154
10155
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_getc(&flip,f))
10156 {
10157 return qe_invalid;
10158 }
10159
10160
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_getc(&extend,f))
10161 {
10162 return qe_invalid;
10163 }
10164
10165 820 poundspr[i][spr_tile]=(int32_t)tile;
10166 820 poundspr[i][spr_flip]=(int32_t)flip;
10167 820 poundspr[i][spr_extend]=(int32_t)extend;
10168 820 }
10169
10170
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 if(!p_igetw(&tile,f))
10171 {
10172 return qe_invalid;
10173 }
10174
10175 205 flip=0;
10176
10177
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 205 times.
205 if(v_herosprites>0)
10178 {
10179
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 if(!p_getc(&flip,f))
10180 {
10181 return qe_invalid;
10182 }
10183 205 }
10184
10185
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 if(!p_getc(&extend,f))
10186 {
10187 return qe_invalid;
10188 }
10189
10190 205 castingspr[spr_tile]=(int32_t)tile;
10191 205 castingspr[spr_flip]=(int32_t)flip;
10192 205 castingspr[spr_extend]=(int32_t)extend;
10193
10194
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 if(v_herosprites>0)
10195 {
10196 205 int32_t num_holdsprs = (v_herosprites > 6 ? 3 : 2);
10197
2/2
✓ Branch 0 taken 410 times.
✓ Branch 1 taken 205 times.
615 for(int32_t i=0; i<2; i++)
10198 {
10199
2/2
✓ Branch 0 taken 820 times.
✓ Branch 1 taken 410 times.
1230 for(int32_t j=0; j<num_holdsprs; j++)
10200 {
10201
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_igetw(&tile,f))
10202 {
10203 return qe_invalid;
10204 }
10205
10206
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_getc(&flip,f))
10207 {
10208 return qe_invalid;
10209 }
10210
10211
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_getc(&extend,f))
10212 {
10213 return qe_invalid;
10214 }
10215
10216 820 holdspr[i][j][spr_tile]=(int32_t)tile;
10217 820 holdspr[i][j][spr_flip]=(int32_t)flip;
10218 820 holdspr[i][j][spr_extend]=(int32_t)extend;
10219 820 }
10220 410 }
10221 205 }
10222 else
10223 {
10224 for(int32_t i=0; i<2; i++)
10225 {
10226 if(!p_igetw(&tile,f))
10227 {
10228 return qe_invalid;
10229 }
10230
10231 if(!p_igetw(&tile2,f))
10232 {
10233 return qe_invalid;
10234 }
10235
10236 if(!p_getc(&extend,f))
10237 {
10238 return qe_invalid;
10239 }
10240
10241 holdspr[i][spr_hold1][spr_tile]=(int32_t)tile;
10242 holdspr[i][spr_hold1][spr_flip]=(int32_t)flip;
10243 holdspr[i][spr_hold1][spr_extend]=(int32_t)extend;
10244 holdspr[i][spr_hold2][spr_tile]=(int32_t)tile2;
10245 holdspr[i][spr_hold2][spr_flip]=(int32_t)flip;
10246 holdspr[i][spr_hold2][spr_extend]=(int32_t)extend;
10247 }
10248 }
10249
10250
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 205 times.
205 if(v_herosprites>2)
10251 {
10252
2/2
✓ Branch 0 taken 820 times.
✓ Branch 1 taken 205 times.
1025 for(int32_t i=0; i<4; i++)
10253 {
10254
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_igetw(&tile,f))
10255 {
10256 return qe_invalid;
10257 }
10258
10259
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_getc(&flip,f))
10260 {
10261 return qe_invalid;
10262 }
10263
10264
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_getc(&extend,f))
10265 {
10266 return qe_invalid;
10267 }
10268
10269 820 jumpspr[i][spr_tile]=(int32_t)tile;
10270 820 jumpspr[i][spr_flip]=(int32_t)flip;
10271 820 jumpspr[i][spr_extend]=(int32_t)extend;
10272 820 }
10273 205 }
10274
10275
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 205 times.
205 if(v_herosprites>3)
10276 {
10277
2/2
✓ Branch 0 taken 820 times.
✓ Branch 1 taken 205 times.
1025 for(int32_t i=0; i<4; i++)
10278 {
10279
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_igetw(&tile,f))
10280 {
10281 return qe_invalid;
10282 }
10283
10284
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_getc(&flip,f))
10285 {
10286 return qe_invalid;
10287 }
10288
10289
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 820 times.
820 if(!p_getc(&extend,f))
10290 {
10291 return qe_invalid;
10292 }
10293
10294 820 chargespr[i][spr_tile]=(int32_t)tile;
10295 820 chargespr[i][spr_flip]=(int32_t)flip;
10296 820 chargespr[i][spr_extend]=(int32_t)extend;
10297 820 }
10298 205 }
10299
10300
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 205 times.
205 if(v_herosprites>4)
10301 {
10302
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 if(!p_getc(&dummy_byte,f))
10303 {
10304 return qe_invalid;
10305 }
10306
10307 205 zinit.hero_swim_speed=(byte)dummy_byte;
10308 205 }
10309
10310 205 memset(frozenspr, 0, sizeof(frozenspr));
10311 205 memset(frozen_waterspr, 0, sizeof(frozen_waterspr));
10312 205 memset(onfirespr, 0, sizeof(onfirespr));
10313 205 memset(onfire_waterspr, 0, sizeof(onfire_waterspr));
10314 205 memset(diggingspr, 0, sizeof(diggingspr));
10315 205 memset(usingrodspr, 0, sizeof(usingrodspr));
10316 205 memset(usingcanespr, 0, sizeof(usingcanespr));
10317 205 memset(pushingspr, 0, sizeof(pushingspr));
10318 205 memset(liftingspr, 0, sizeof(liftingspr));
10319 205 memset(liftingwalkspr, 0, sizeof(liftingwalkspr));
10320 205 memset(stunnedspr, 0, sizeof(stunnedspr));
10321 205 memset(stunned_waterspr, 0, sizeof(stunned_waterspr));
10322 205 memset(fallingspr, 0, sizeof(fallingspr));
10323 205 memset(shockedspr, 0, sizeof(shockedspr));
10324 205 memset(shocked_waterspr, 0, sizeof(shocked_waterspr));
10325 205 memset(pullswordspr, 0, sizeof(pullswordspr));
10326 205 memset(readingspr, 0, sizeof(readingspr));
10327 205 memset(slash180spr, 0, sizeof(slash180spr));
10328 205 memset(slashZ4spr, 0, sizeof(slashZ4spr));
10329 205 memset(dashspr, 0, sizeof(dashspr));
10330 205 memset(bonkspr, 0, sizeof(bonkspr));
10331 205 memset(medallionsprs, 0, sizeof(medallionsprs));
10332 205 memset(holdspr[0][2], 0, sizeof(holdspr[0][2])); //Sword hold (Land)
10333 205 memset(holdspr[1][2], 0, sizeof(holdspr[1][2])); //Sword hold (Water)
10334
2/2
✓ Branch 0 taken 820 times.
✓ Branch 1 taken 205 times.
1025 for(int32_t q = 0; q < 4; ++q)
10335 {
10336
2/2
✓ Branch 0 taken 2460 times.
✓ Branch 1 taken 820 times.
3280 for(int32_t p = 0; p < 3; ++p)
10337 {
10338 2460 drowningspr[q][p] = divespr[q][p];
10339 2460 drowning_lavaspr[q][p] = divespr[q][p];
10340 2460 }
10341 820 }
10342 205 memset(sideswimspr, 0, sizeof(sideswimspr));
10343 205 memset(sideswimslashspr, 0, sizeof(sideswimslashspr));
10344 205 memset(sideswimstabspr, 0, sizeof(sideswimstabspr));
10345 205 memset(sideswimpoundspr, 0, sizeof(sideswimpoundspr));
10346 205 memset(sideswimchargespr, 0, sizeof(sideswimchargespr));
10347 205 memset(sideswimholdspr, 0, sizeof(sideswimholdspr));
10348 205 memset(sidedrowningspr, 0, sizeof(sidedrowningspr));
10349 205 }
10350
10351
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 310 times.
310 if(FFCore.quest_format[vInitData] < 34)
10352 {
10353 310 bool fastswim = zinit.hero_swim_speed > 60;
10354 // '2/3' or '1/2'
10355 310 zinit.hero_swim_mult = fastswim ? 2 : 1;
10356 310 zinit.hero_swim_div = fastswim ? 3 : 2;
10357 310 }
10358 310 return 0;
10359 310 }
10360
10361 32300 void setSprite(int32_t* arr, int32_t tile, int32_t flip, int32_t ext)
10362 {
10363 32300 arr[spr_tile] = tile;
10364
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32300 times.
32300 arr[spr_flip] = (flip > 3 ? 0 : flip);
10365
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32300 times.
32300 arr[spr_extend] = (ext > 2 ? 0 : ext);
10366 32300 }
10367 //Used to read the player sprites as int32_t, not word.
10368 190 int32_t readherosprites3(PACKFILE *f, int32_t v_herosprites)
10369 {
10370 190 zinit.hero_swim_speed=67; //default
10371 190 setupherotiles(zinit.heroAnimationStyle);
10372 190 setupherodefenses();
10373 190 setupherooffsets();
10374
10375 int32_t tile, tile2;
10376 byte flip, extend, dummy_byte;
10377
10378
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if(v_herosprites>=0)
10379 {
10380
10381
2/2
✓ Branch 0 taken 760 times.
✓ Branch 1 taken 190 times.
950 for(int32_t i=0; i<4; i++)
10382 {
10383
1/2
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
760 if(!p_igetl(&tile,f))
10384 {
10385 return qe_invalid;
10386 }
10387
10388
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 760 times.
760 if(!p_getc(&flip,f))
10389 {
10390 return qe_invalid;
10391 }
10392
10393
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 760 times.
760 if(!p_getc(&extend,f))
10394 {
10395 return qe_invalid;
10396 }
10397
10398 760 setSprite(walkspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10399 760 }
10400
10401
2/2
✓ Branch 0 taken 760 times.
✓ Branch 1 taken 190 times.
950 for(int32_t i=0; i<4; i++)
10402 {
10403
1/2
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
760 if(!p_igetl(&tile,f))
10404 {
10405 return qe_invalid;
10406 }
10407
10408
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 760 times.
760 if(!p_getc(&flip,f))
10409 {
10410 return qe_invalid;
10411 }
10412
10413
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 760 times.
760 if(!p_getc(&extend,f))
10414 {
10415 return qe_invalid;
10416 }
10417
10418 760 setSprite(stabspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10419 760 }
10420
10421
2/2
✓ Branch 0 taken 760 times.
✓ Branch 1 taken 190 times.
950 for(int32_t i=0; i<4; i++)
10422 {
10423
1/2
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
760 if(!p_igetl(&tile,f))
10424 {
10425 return qe_invalid;
10426 }
10427
10428
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 760 times.
760 if(!p_getc(&flip,f))
10429 {
10430 return qe_invalid;
10431 }
10432
10433
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 760 times.
760 if(!p_getc(&extend,f))
10434 {
10435 return qe_invalid;
10436 }
10437
10438 760 setSprite(slashspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10439 760 }
10440
10441
2/2
✓ Branch 0 taken 760 times.
✓ Branch 1 taken 190 times.
950 for(int32_t i=0; i<4; i++)
10442 {
10443
1/2
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
760 if(!p_igetl(&tile,f))
10444 {
10445 return qe_invalid;
10446 }
10447
10448
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 760 times.
760 if(!p_getc(&flip,f))
10449 {
10450 return qe_invalid;
10451 }
10452
10453
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 760 times.
760 if(!p_getc(&extend,f))
10454 {
10455 return qe_invalid;
10456 }
10457
10458 760 setSprite(floatspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10459 760 }
10460
10461
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if(v_herosprites>1)
10462 {
10463
2/2
✓ Branch 0 taken 760 times.
✓ Branch 1 taken 190 times.
950 for(int32_t i=0; i<4; i++)
10464 {
10465
1/2
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
760 if(!p_igetl(&tile,f))
10466 {
10467 return qe_invalid;
10468 }
10469
10470
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 760 times.
760 if(!p_getc(&flip,f))
10471 {
10472 return qe_invalid;
10473 }
10474
10475
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 760 times.
760 if(!p_getc(&extend,f))
10476 {
10477 return qe_invalid;
10478 }
10479
10480 760 setSprite(swimspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10481 760 }
10482 190 }
10483
10484
2/2
✓ Branch 0 taken 760 times.
✓ Branch 1 taken 190 times.
950 for(int32_t i=0; i<4; i++)
10485 {
10486
1/2
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
760 if(!p_igetl(&tile,f))
10487 {
10488 return qe_invalid;
10489 }
10490
10491
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 760 times.
760 if(!p_getc(&flip,f))
10492 {
10493 return qe_invalid;
10494 }
10495
10496
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 760 times.
760 if(!p_getc(&extend,f))
10497 {
10498 return qe_invalid;
10499 }
10500
10501 760 setSprite(divespr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10502 760 }
10503
10504
2/2
✓ Branch 0 taken 760 times.
✓ Branch 1 taken 190 times.
950 for(int32_t i=0; i<4; i++)
10505 {
10506
1/2
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
760 if(!p_igetl(&tile,f))
10507 {
10508 return qe_invalid;
10509 }
10510
10511
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 760 times.
760 if(!p_getc(&flip,f))
10512 {
10513 return qe_invalid;
10514 }
10515
10516
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 760 times.
760 if(!p_getc(&extend,f))
10517 {
10518 return qe_invalid;
10519 }
10520
10521 760 setSprite(poundspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10522 760 }
10523
10524
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if(!p_igetl(&tile,f))
10525 {
10526 return qe_invalid;
10527 }
10528
10529 190 flip=0;
10530
10531
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if(v_herosprites>0)
10532 {
10533
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if(!p_getc(&flip,f))
10534 {
10535 return qe_invalid;
10536 }
10537 190 }
10538
10539
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if(!p_getc(&extend,f))
10540 {
10541 return qe_invalid;
10542 }
10543
10544 190 setSprite(castingspr, int32_t(tile), int32_t(flip), int32_t(extend));
10545
10546
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if(v_herosprites>0)
10547 {
10548 190 int32_t num_holdsprs = (v_herosprites > 6 ? 3 : 2);
10549
2/2
✓ Branch 0 taken 380 times.
✓ Branch 1 taken 190 times.
570 for(int32_t i=0; i<2; i++)
10550 {
10551
2/2
✓ Branch 0 taken 1140 times.
✓ Branch 1 taken 380 times.
1520 for(int32_t j=0; j<num_holdsprs; j++)
10552 {
10553
1/2
✓ Branch 0 taken 1140 times.
✗ Branch 1 not taken.
1140 if(!p_igetl(&tile,f))
10554 {
10555 return qe_invalid;
10556 }
10557
10558
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1140 times.
1140 if(!p_getc(&flip,f))
10559 {
10560 return qe_invalid;
10561 }
10562
10563
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1140 times.
1140 if(!p_getc(&extend,f))
10564 {
10565 return qe_invalid;
10566 }
10567
10568 1140 setSprite(holdspr[i][j], int32_t(tile), int32_t(flip), int32_t(extend));
10569 1140 }
10570 380 }
10571 190 }
10572 else
10573 {
10574 for(int32_t i=0; i<2; i++)
10575 {
10576 if(!p_igetl(&tile,f))
10577 {
10578 return qe_invalid;
10579 }
10580
10581 if(!p_igetl(&tile2,f))
10582 {
10583 return qe_invalid;
10584 }
10585
10586 if(!p_getc(&extend,f))
10587 {
10588 return qe_invalid;
10589 }
10590
10591 setSprite(holdspr[i][spr_hold1], int32_t(tile), int32_t(flip), int32_t(extend));
10592 setSprite(holdspr[i][spr_hold2], int32_t(tile2), int32_t(flip), int32_t(extend));
10593 }
10594 }
10595
10596
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if(v_herosprites>2)
10597 {
10598
2/2
✓ Branch 0 taken 760 times.
✓ Branch 1 taken 190 times.
950 for(int32_t i=0; i<4; i++)
10599 {
10600
1/2
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
760 if(!p_igetl(&tile,f))
10601 {
10602 return qe_invalid;
10603 }
10604
10605
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 760 times.
760 if(!p_getc(&flip,f))
10606 {
10607 return qe_invalid;
10608 }
10609
10610
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 760 times.
760 if(!p_getc(&extend,f))
10611 {
10612 return qe_invalid;
10613 }
10614
10615 760 setSprite(jumpspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10616 760 }
10617 190 }
10618
10619
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if(v_herosprites>3)
10620 {
10621
2/2
✓ Branch 0 taken 760 times.
✓ Branch 1 taken 190 times.
950 for(int32_t i=0; i<4; i++)
10622 {
10623
1/2
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
760 if(!p_igetl(&tile,f))
10624 {
10625 return qe_invalid;
10626 }
10627
10628
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 760 times.
760 if(!p_getc(&flip,f))
10629 {
10630 return qe_invalid;
10631 }
10632
10633
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 760 times.
760 if(!p_getc(&extend,f))
10634 {
10635 return qe_invalid;
10636 }
10637
10638 760 setSprite(chargespr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10639 760 }
10640 190 }
10641
10642
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if(v_herosprites>4)
10643 {
10644
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if(!p_getc(&dummy_byte,f))
10645 {
10646 return qe_invalid;
10647 }
10648
10649 190 zinit.hero_swim_speed=(byte)dummy_byte;
10650 190 }
10651
10652
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if(v_herosprites>6)
10653 {
10654
2/2
✓ Branch 0 taken 760 times.
✓ Branch 1 taken 190 times.
950 for(int32_t q = 0; q < 4; ++q)
10655 {
10656
1/2
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
760 if(!p_igetl(&tile,f))
10657 return qe_invalid;
10658
10659
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 760 times.
760 if(!p_getc(&flip,f))
10660 return qe_invalid;
10661
10662
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 760 times.
760 if(!p_getc(&extend,f))
10663 return qe_invalid;
10664
10665 760 setSprite(frozenspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10666 760 }
10667
2/2
✓ Branch 0 taken 760 times.
✓ Branch 1 taken 190 times.
950 for(int32_t q = 0; q < 4; ++q)
10668 {
10669
1/2
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
760 if(!p_igetl(&tile,f))
10670 return qe_invalid;
10671
10672
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 760 times.
760 if(!p_getc(&flip,f))
10673 return qe_invalid;
10674
10675
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 760 times.
760 if(!p_getc(&extend,f))
10676 return qe_invalid;
10677
10678 760 setSprite(frozen_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10679 760 }
10680
10681
2/2
✓ Branch 0 taken 760 times.
✓ Branch 1 taken 190 times.
950 for(int32_t q = 0; q < 4; ++q)
10682 {
10683
1/2
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
760 if(!p_igetl(&tile,f))
10684 return qe_invalid;
10685
10686
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 760 times.
760 if(!p_getc(&flip,f))
10687 return qe_invalid;
10688
10689
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 760 times.
760 if(!p_getc(&extend,f))
10690 return qe_invalid;
10691
10692 760 setSprite(onfirespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10693 760 }
10694
2/2
✓ Branch 0 taken 760 times.
✓ Branch 1 taken 190 times.
950 for(int32_t q = 0; q < 4; ++q)
10695 {
10696
1/2
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
760 if(!p_igetl(&tile,f))
10697 return qe_invalid;
10698
10699
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 760 times.
760 if(!p_getc(&flip,f))
10700 return qe_invalid;
10701
10702
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 760 times.
760 if(!p_getc(&extend,f))
10703 return qe_invalid;
10704
10705 760 setSprite(onfire_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10706 760 }
10707
10708
2/2
✓ Branch 0 taken 760 times.
✓ Branch 1 taken 190 times.
950 for(int32_t q = 0; q < 4; ++q)
10709 {
10710
1/2
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
760 if(!p_igetl(&tile,f))
10711 return qe_invalid;
10712
10713
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 760 times.
760 if(!p_getc(&flip,f))
10714 return qe_invalid;
10715
10716
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 760 times.
760 if(!p_getc(&extend,f))
10717 return qe_invalid;
10718
10719 760 setSprite(diggingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10720 760 }
10721
10722
2/2
✓ Branch 0 taken 760 times.
✓ Branch 1 taken 190 times.
950 for(int32_t q = 0; q < 4; ++q)
10723 {
10724
1/2
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
760 if(!p_igetl(&tile,f))
10725 return qe_invalid;
10726
10727
1/2
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
760 if(!p_getc(&flip,f))
10728 return qe_invalid;
10729
10730
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 760 times.
760 if(!p_getc(&extend,f))
10731 return qe_invalid;
10732
10733 760 setSprite(usingrodspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10734 760 }
10735
10736
2/2
✓ Branch 0 taken 760 times.
✓ Branch 1 taken 190 times.
950 for(int32_t q = 0; q < 4; ++q)
10737 {
10738
1/2
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
760 if(!p_igetl(&tile,f))
10739 return qe_invalid;
10740
10741
1/2
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
760 if(!p_getc(&flip,f))
10742 return qe_invalid;
10743
10744
1/2
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
760 if(!p_getc(&extend,f))
10745 return qe_invalid;
10746
10747 760 setSprite(usingcanespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10748 760 }
10749
10750
2/2
✓ Branch 0 taken 760 times.
✓ Branch 1 taken 190 times.
950 for(int32_t q = 0; q < 4; ++q)
10751 {
10752
1/2
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
760 if(!p_igetl(&tile,f))
10753 return qe_invalid;
10754
10755
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 760 times.
760 if(!p_getc(&flip,f))
10756 return qe_invalid;
10757
10758
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 760 times.
760 if(!p_getc(&extend,f))
10759 return qe_invalid;
10760
10761 760 setSprite(pushingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10762 760 }
10763
10764
2/2
✓ Branch 0 taken 760 times.
✓ Branch 1 taken 190 times.
950 for(int32_t q = 0; q < 4; ++q)
10765 {
10766
1/2
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
760 if(!p_igetl(&tile,f))
10767 return qe_invalid;
10768
10769
1/2
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
760 if(!p_getc(&flip,f))
10770 return qe_invalid;
10771
10772
1/2
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
760 if(!p_getc(&extend,f))
10773 return qe_invalid;
10774
10775 760 byte frames = 0;
10776
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 740 times.
760 if(v_herosprites > 15)
10777 {
10778
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 740 times.
740 if(!p_getc(&frames,f))
10779 return qe_invalid;
10780 740 }
10781
10782 760 setSprite(liftingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10783 760 liftingspr[q][spr_frames] = frames;
10784 760 }
10785
10786
2/2
✓ Branch 0 taken 760 times.
✓ Branch 1 taken 190 times.
950 for(int32_t q = 0; q < 4; ++q)
10787 {
10788
1/2
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
760 if(!p_igetl(&tile,f))
10789 return qe_invalid;
10790
10791
1/2
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
760 if(!p_getc(&flip,f))
10792 return qe_invalid;
10793
10794
1/2
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
760 if(!p_getc(&extend,f))
10795 return qe_invalid;
10796
10797 760 setSprite(liftingwalkspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10798 760 }
10799
10800
2/2
✓ Branch 0 taken 760 times.
✓ Branch 1 taken 190 times.
950 for(int32_t q = 0; q < 4; ++q)
10801 {
10802
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 760 times.
760 if(!p_igetl(&tile,f))
10803 return qe_invalid;
10804
10805
1/2
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
760 if(!p_getc(&flip,f))
10806 return qe_invalid;
10807
10808
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 760 times.
760 if(!p_getc(&extend,f))
10809 return qe_invalid;
10810
10811 760 setSprite(stunnedspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10812 760 }
10813
2/2
✓ Branch 0 taken 760 times.
✓ Branch 1 taken 190 times.
950 for(int32_t q = 0; q < 4; ++q)
10814 {
10815
1/2
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
760 if(!p_igetl(&tile,f))
10816 return qe_invalid;
10817
10818
1/2
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
760 if(!p_getc(&flip,f))
10819 return qe_invalid;
10820
10821
1/2
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
760 if(!p_getc(&extend,f))
10822 return qe_invalid;
10823
10824 760 setSprite(stunned_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10825 760 }
10826
10827
2/2
✓ Branch 0 taken 760 times.
✓ Branch 1 taken 190 times.
950 for(int32_t q = 0; q < 4; ++q)
10828 {
10829
1/2
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
760 if(!p_igetl(&tile,f))
10830 return qe_invalid;
10831
10832
1/2
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
760 if(!p_getc(&flip,f))
10833 return qe_invalid;
10834
10835
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 760 times.
760 if(!p_getc(&extend,f))
10836 return qe_invalid;
10837
10838 760 setSprite(drowningspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10839 760 }
10840
10841
2/2
✓ Branch 0 taken 760 times.
✓ Branch 1 taken 190 times.
950 for(int32_t q = 0; q < 4; ++q)
10842 {
10843
1/2
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
760 if(!p_igetl(&tile,f))
10844 return qe_invalid;
10845
10846
1/2
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
760 if(!p_getc(&flip,f))
10847 return qe_invalid;
10848
10849
1/2
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
760 if(!p_getc(&extend,f))
10850 return qe_invalid;
10851
10852 760 setSprite(drowning_lavaspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10853 760 }
10854
10855
2/2
✓ Branch 0 taken 760 times.
✓ Branch 1 taken 190 times.
950 for(int32_t q = 0; q < 4; ++q)
10856 {
10857
1/2
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
760 if(!p_igetl(&tile,f))
10858 return qe_invalid;
10859
10860
1/2
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
760 if(!p_getc(&flip,f))
10861 return qe_invalid;
10862
10863
1/2
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
760 if(!p_getc(&extend,f))
10864 return qe_invalid;
10865
10866 760 setSprite(fallingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10867 760 }
10868
10869
2/2
✓ Branch 0 taken 760 times.
✓ Branch 1 taken 190 times.
950 for(int32_t q = 0; q < 4; ++q)
10870 {
10871
1/2
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
760 if(!p_igetl(&tile,f))
10872 return qe_invalid;
10873
10874
1/2
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
760 if(!p_getc(&flip,f))
10875 return qe_invalid;
10876
10877
1/2
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
760 if(!p_getc(&extend,f))
10878 return qe_invalid;
10879
10880 760 setSprite(shockedspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10881 760 }
10882
2/2
✓ Branch 0 taken 760 times.
✓ Branch 1 taken 190 times.
950 for(int32_t q = 0; q < 4; ++q)
10883 {
10884
1/2
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
760 if(!p_igetl(&tile,f))
10885 return qe_invalid;
10886
10887
1/2
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
760 if(!p_getc(&flip,f))
10888 return qe_invalid;
10889
10890
1/2
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
760 if(!p_getc(&extend,f))
10891 return qe_invalid;
10892
10893 760 setSprite(shocked_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10894 760 }
10895
10896
2/2
✓ Branch 0 taken 760 times.
✓ Branch 1 taken 190 times.
950 for(int32_t q = 0; q < 4; ++q)
10897 {
10898
1/2
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
760 if(!p_igetl(&tile,f))
10899 return qe_invalid;
10900
10901
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 760 times.
760 if(!p_getc(&flip,f))
10902 return qe_invalid;
10903
10904
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 760 times.
760 if(!p_getc(&extend,f))
10905 return qe_invalid;
10906
10907 760 setSprite(pullswordspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10908 760 }
10909
10910
2/2
✓ Branch 0 taken 760 times.
✓ Branch 1 taken 190 times.
950 for(int32_t q = 0; q < 4; ++q)
10911 {
10912
1/2
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
760 if(!p_igetl(&tile,f))
10913 return qe_invalid;
10914
10915
1/2
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
760 if(!p_getc(&flip,f))
10916 return qe_invalid;
10917
10918
1/2
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
760 if(!p_getc(&extend,f))
10919 return qe_invalid;
10920
10921 760 setSprite(readingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10922 760 }
10923
10924
2/2
✓ Branch 0 taken 760 times.
✓ Branch 1 taken 190 times.
950 for(int32_t q = 0; q < 4; ++q)
10925 {
10926
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 760 times.
760 if(!p_igetl(&tile,f))
10927 return qe_invalid;
10928
10929
1/2
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
760 if(!p_getc(&flip,f))
10930 return qe_invalid;
10931
10932
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 760 times.
760 if(!p_getc(&extend,f))
10933 return qe_invalid;
10934
10935 760 setSprite(slash180spr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10936 760 }
10937
10938
2/2
✓ Branch 0 taken 760 times.
✓ Branch 1 taken 190 times.
950 for(int32_t q = 0; q < 4; ++q)
10939 {
10940
1/2
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
760 if(!p_igetl(&tile,f))
10941 return qe_invalid;
10942
10943
1/2
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
760 if(!p_getc(&flip,f))
10944 return qe_invalid;
10945
10946
1/2
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
760 if(!p_getc(&extend,f))
10947 return qe_invalid;
10948
10949 760 setSprite(slashZ4spr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10950 760 }
10951
10952
2/2
✓ Branch 0 taken 760 times.
✓ Branch 1 taken 190 times.
950 for(int32_t q = 0; q < 4; ++q)
10953 {
10954
1/2
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
760 if(!p_igetl(&tile,f))
10955 return qe_invalid;
10956
10957
1/2
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
760 if(!p_getc(&flip,f))
10958 return qe_invalid;
10959
10960
1/2
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
760 if(!p_getc(&extend,f))
10961 return qe_invalid;
10962
10963 760 setSprite(dashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10964 760 }
10965
10966
2/2
✓ Branch 0 taken 760 times.
✓ Branch 1 taken 190 times.
950 for(int32_t q = 0; q < 4; ++q)
10967 {
10968
1/2
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
760 if(!p_igetl(&tile,f))
10969 return qe_invalid;
10970
10971
1/2
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
760 if(!p_getc(&flip,f))
10972 return qe_invalid;
10973
10974
1/2
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
760 if(!p_getc(&extend,f))
10975 return qe_invalid;
10976
10977 760 setSprite(bonkspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10978 760 }
10979
10980
2/2
✓ Branch 0 taken 570 times.
✓ Branch 1 taken 190 times.
760 for(int32_t q = 0; q < 3; ++q) //Not directions; number of medallion sprs
10981 {
10982
1/2
✓ Branch 0 taken 570 times.
✗ Branch 1 not taken.
570 if(!p_igetl(&tile,f))
10983 return qe_invalid;
10984
10985
1/2
✓ Branch 0 taken 570 times.
✗ Branch 1 not taken.
570 if(!p_getc(&flip,f))
10986 return qe_invalid;
10987
10988
1/2
✓ Branch 0 taken 570 times.
✗ Branch 1 not taken.
570 if(!p_getc(&extend,f))
10989 return qe_invalid;
10990
10991 570 setSprite(medallionsprs[q], int32_t(tile), int32_t(flip), int32_t(extend));
10992 570 }
10993 190 }
10994 else
10995 {
10996 memset(frozenspr, 0, sizeof(frozenspr));
10997 memset(frozen_waterspr, 0, sizeof(frozen_waterspr));
10998 memset(onfirespr, 0, sizeof(onfirespr));
10999 memset(onfire_waterspr, 0, sizeof(onfire_waterspr));
11000 memset(diggingspr, 0, sizeof(diggingspr));
11001 memset(usingrodspr, 0, sizeof(usingrodspr));
11002 memset(usingcanespr, 0, sizeof(usingcanespr));
11003 memset(pushingspr, 0, sizeof(pushingspr));
11004 memset(liftingspr, 0, sizeof(liftingspr));
11005 memset(liftingwalkspr, 0, sizeof(liftingwalkspr));
11006 memset(stunnedspr, 0, sizeof(stunnedspr));
11007 memset(stunned_waterspr, 0, sizeof(stunned_waterspr));
11008 memset(fallingspr, 0, sizeof(fallingspr));
11009 memset(shockedspr, 0, sizeof(shockedspr));
11010 memset(shocked_waterspr, 0, sizeof(shocked_waterspr));
11011 memset(pullswordspr, 0, sizeof(pullswordspr));
11012 memset(readingspr, 0, sizeof(readingspr));
11013 memset(slash180spr, 0, sizeof(slash180spr));
11014 memset(slashZ4spr, 0, sizeof(slashZ4spr));
11015 memset(dashspr, 0, sizeof(dashspr));
11016 memset(bonkspr, 0, sizeof(bonkspr));
11017 memset(medallionsprs, 0, sizeof(medallionsprs));
11018 memset(holdspr[0][2], 0, sizeof(holdspr[0][2])); //Sword hold (Land)
11019 memset(holdspr[1][2], 0, sizeof(holdspr[1][2])); //Sword hold (Water)
11020 for(int32_t q = 0; q < 4; ++q)
11021 {
11022 for(int32_t p = 0; p < 3; ++p)
11023 {
11024 drowningspr[q][p] = divespr[q][p];
11025 drowning_lavaspr[q][p] = divespr[q][p];
11026 }
11027 }
11028 }
11029
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if (v_herosprites > 8)
11030 {
11031
2/2
✓ Branch 0 taken 760 times.
✓ Branch 1 taken 190 times.
950 for(int32_t q = 0; q < 4; ++q)
11032 {
11033
1/2
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
760 if(!p_igetl(&tile,f))
11034 return qe_invalid;
11035
11036
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 760 times.
760 if(!p_getc(&flip,f))
11037 return qe_invalid;
11038
11039
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 760 times.
760 if(!p_getc(&extend,f))
11040 return qe_invalid;
11041
11042 760 setSprite(sideswimspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11043 760 }
11044 190 }
11045 else
11046 {
11047 memset(sideswimspr, 0, sizeof(sideswimspr));
11048 }
11049
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if (v_herosprites > 9)
11050 {
11051
2/2
✓ Branch 0 taken 760 times.
✓ Branch 1 taken 190 times.
950 for(int32_t q = 0; q < 4; ++q)
11052 {
11053
1/2
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
760 if(!p_igetl(&tile,f))
11054 return qe_invalid;
11055
11056
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 760 times.
760 if(!p_getc(&flip,f))
11057 return qe_invalid;
11058
11059
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 760 times.
760 if(!p_getc(&extend,f))
11060 return qe_invalid;
11061
11062 760 setSprite(sideswimslashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11063 760 }
11064
2/2
✓ Branch 0 taken 760 times.
✓ Branch 1 taken 190 times.
950 for(int32_t q = 0; q < 4; ++q)
11065 {
11066
1/2
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
760 if(!p_igetl(&tile,f))
11067 return qe_invalid;
11068
11069
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 760 times.
760 if(!p_getc(&flip,f))
11070 return qe_invalid;
11071
11072
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 760 times.
760 if(!p_getc(&extend,f))
11073 return qe_invalid;
11074
11075 760 setSprite(sideswimstabspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11076 760 }
11077
2/2
✓ Branch 0 taken 760 times.
✓ Branch 1 taken 190 times.
950 for(int32_t q = 0; q < 4; ++q)
11078 {
11079
1/2
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
760 if(!p_igetl(&tile,f))
11080 return qe_invalid;
11081
11082
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 760 times.
760 if(!p_getc(&flip,f))
11083 return qe_invalid;
11084
11085
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 760 times.
760 if(!p_getc(&extend,f))
11086 return qe_invalid;
11087
11088 760 setSprite(sideswimpoundspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11089 760 }
11090
2/2
✓ Branch 0 taken 760 times.
✓ Branch 1 taken 190 times.
950 for(int32_t q = 0; q < 4; ++q)
11091 {
11092
1/2
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
760 if(!p_igetl(&tile,f))
11093 return qe_invalid;
11094
11095
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 760 times.
760 if(!p_getc(&flip,f))
11096 return qe_invalid;
11097
11098
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 760 times.
760 if(!p_getc(&extend,f))
11099 return qe_invalid;
11100
11101 760 setSprite(sideswimchargespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11102 760 }
11103 190 }
11104 else
11105 {
11106 memset(sideswimslashspr, 0, sizeof(sideswimslashspr));
11107 memset(sideswimstabspr, 0, sizeof(sideswimstabspr));
11108 memset(sideswimpoundspr, 0, sizeof(sideswimpoundspr));
11109 memset(sideswimchargespr, 0, sizeof(sideswimchargespr));
11110 }
11111
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if (v_herosprites > 10)
11112 {
11113
2/2
✓ Branch 0 taken 760 times.
✓ Branch 1 taken 190 times.
950 for(int32_t q = 0; q < 4; ++q)
11114 {
11115 int32_t hmr;
11116
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 760 times.
760 if(!p_igetl(&hmr,f))
11117 return qe_invalid;
11118
11119 760 hammeroffsets[q] = hmr;
11120 760 }
11121 190 }
11122 else
11123 {
11124 for(int32_t q = 0; q < 4; ++q) hammeroffsets[q] = 0;
11125 }
11126
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if (v_herosprites > 11)
11127 {
11128
2/2
✓ Branch 0 taken 570 times.
✓ Branch 1 taken 190 times.
760 for(int32_t q = 0; q < 3; ++q)
11129 {
11130
1/2
✓ Branch 0 taken 570 times.
✗ Branch 1 not taken.
570 if(!p_igetl(&tile,f))
11131 return qe_invalid;
11132
11133
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 570 times.
570 if(!p_getc(&flip,f))
11134 return qe_invalid;
11135
11136
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 570 times.
570 if(!p_getc(&extend,f))
11137 return qe_invalid;
11138
11139 570 setSprite(sideswimholdspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11140 570 }
11141 190 }
11142 else
11143 {
11144 memset(sideswimholdspr, 0, sizeof(sideswimholdspr));
11145 }
11146
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if (v_herosprites > 12)
11147 {
11148
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if(!p_igetl(&tile,f))
11149 return qe_invalid;
11150
11151
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if(!p_getc(&flip,f))
11152 return qe_invalid;
11153
11154
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if(!p_getc(&extend,f))
11155 return qe_invalid;
11156 190 setSprite(sideswimcastingspr, int32_t(tile), int32_t(flip), int32_t(extend));
11157
11158 190 }
11159 else
11160 {
11161 memset(sideswimcastingspr, 0, sizeof(sideswimcastingspr));
11162 }
11163
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if (v_herosprites > 13)
11164 {
11165
2/2
✓ Branch 0 taken 760 times.
✓ Branch 1 taken 190 times.
950 for(int32_t q = 0; q < 4; ++q)
11166 {
11167
1/2
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
760 if(!p_igetl(&tile,f))
11168 return qe_invalid;
11169
11170
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 760 times.
760 if(!p_getc(&flip,f))
11171 return qe_invalid;
11172
11173
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 760 times.
760 if(!p_getc(&extend,f))
11174 return qe_invalid;
11175
11176 760 setSprite(sidedrowningspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11177 760 }
11178 190 }
11179 else
11180 {
11181 memset(sidedrowningspr, 0, sizeof(sidedrowningspr));
11182 }
11183
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if (v_herosprites > 14)
11184 {
11185
2/2
✓ Branch 0 taken 760 times.
✓ Branch 1 taken 190 times.
950 for(int32_t q = 0; q < 4; ++q)
11186 {
11187
1/2
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
760 if(!p_igetl(&tile,f))
11188 return qe_invalid;
11189
11190
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 760 times.
760 if(!p_getc(&flip,f))
11191 return qe_invalid;
11192
11193
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 760 times.
760 if(!p_getc(&extend,f))
11194 return qe_invalid;
11195
11196 760 setSprite(revslashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11197 760 }
11198 190 }
11199 else
11200 {
11201 memset(revslashspr, 0, sizeof(revslashspr));
11202 }
11203
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if (v_herosprites > 7)
11204 {
11205 190 int32_t num_defense = wMax;
11206 190 byte def = 0;
11207
11208 //Set num_defense accordingly if changes to enum require version upgrade - Jman
11209 /*if(v_herosprites > [x])
11210 * {
11211 * num_defense = 146 //value of wMax on version 8
11212 * }
11213 */
11214
11215
2/2
✓ Branch 0 taken 27740 times.
✓ Branch 1 taken 190 times.
27930 for (int32_t q = 0; q < num_defense; q++)
11216 {
11217
1/2
✓ Branch 0 taken 27740 times.
✗ Branch 1 not taken.
27740 if (!p_getc(&def, f))
11218 return qe_invalid;
11219
11220 27740 hero_defenses[q] = def;
11221 27740 }
11222 190 }
11223 else
11224 {
11225 int32_t num_defense = wMax;
11226 for (int32_t q = 0; q < num_defense; q++)
11227 {
11228 hero_defenses[q] = 0;
11229 }
11230 }
11231 190 }
11232
11233
2/2
✓ Branch 0 taken 179 times.
✓ Branch 1 taken 11 times.
190 if(FFCore.quest_format[vInitData] < 34)
11234 {
11235 11 bool fastswim = zinit.hero_swim_speed > 60;
11236 // '2/3' or '1/2'
11237 11 zinit.hero_swim_mult = fastswim ? 2 : 1;
11238 11 zinit.hero_swim_div = fastswim ? 3 : 2;
11239 11 }
11240 190 return 0;
11241 190 }
11242
11243
11244 395 int32_t readherosprites(PACKFILE *f, zquestheader *Header)
11245 {
11246 //these are here to bypass compiler warnings about unused arguments
11247 395 Header=Header;
11248
11249 dword dummy;
11250 395 word s_version=0;
11251
11252 //section version info
11253
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 395 times.
395 if(!p_igetw(&s_version,f))
11254 {
11255 return qe_invalid;
11256 }
11257
11258 395 FFCore.quest_format[vHeroSprites] = s_version;
11259
11260
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 if(!read_deprecated_section_cversion(f))
11261 {
11262 return qe_invalid;
11263 }
11264
11265 //section size
11266
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 if(!p_igetl(&dummy,f))
11267 {
11268 return qe_invalid;
11269 }
11270
2/2
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 205 times.
395 if ( s_version >= 6 )
11271 {
11272 190 return readherosprites3(f, s_version);
11273 }
11274 205 else return readherosprites2(f, s_version);
11275 395 }
11276
11277 222 int32_t read_old_subscreens(PACKFILE *f, word s_version)
11278 {
11279 222 subscreens_active.clear();
11280 222 subscreens_passive.clear();
11281 222 subscreens_overlay.clear();
11282
2/2
✓ Branch 0 taken 28416 times.
✓ Branch 1 taken 222 times.
28638 for(int32_t i=0; i<MAXCUSTOMSUBSCREENS; i++)
11283 {
11284 subscreen_group g;
11285 28416 memset(&g,0,sizeof(subscreen_group));
11286 28416 int32_t ret = read_one_old_subscreen(f, &g, s_version);
11287
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28416 times.
28416 if(ret!=0)
11288 return ret;
11289
2/2
✓ Branch 0 taken 1161 times.
✓ Branch 1 taken 27255 times.
28416 if(g.objects[0].type == ssoNULL) continue;
11290
2/2
✓ Branch 0 taken 485 times.
✓ Branch 1 taken 676 times.
1161 auto& vec = g.ss_type == sstPASSIVE ? subscreens_passive : subscreens_active;
11291 1161 ZCSubscreen& sub = vec.emplace_back();
11292 1161 sub.load_old(g);
11293 1161 }
11294
11295 222 return 0;
11296 222 }
11297
11298 28416 int32_t read_one_old_subscreen(PACKFILE *f, subscreen_group* g, word s_version)
11299 {
11300 28416 int32_t numsub=0;
11301 28416 byte temp_ss=0;
11302 subscreen_object temp_sub_stack;
11303 28416 subscreen_object *temp_sub = &temp_sub_stack;
11304
11305 char tempname[64];
11306
11307 // FWIW I never saw anything bigger than 20.
11308 #define MAX_DP1_LEN 1024
11309 char tempdp1[MAX_DP1_LEN];
11310
11311
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28416 times.
28416 if(!pfread(tempname,64,f))
11312 {
11313 return qe_invalid;
11314 }
11315
11316
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28416 times.
28416 if(s_version > 1)
11317 {
11318
1/2
✓ Branch 0 taken 28416 times.
✗ Branch 1 not taken.
28416 if(!p_getc(&temp_ss,f))
11319 {
11320 return qe_invalid;
11321 }
11322 28416 }
11323
11324
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28416 times.
28416 if(s_version < 4)
11325 {
11326 uint8_t tmp=0;
11327
11328 if(!p_getc(&tmp,f))
11329 {
11330 return qe_invalid;
11331 }
11332
11333 numsub = (int32_t)tmp;
11334 }
11335 else
11336 {
11337 word tmp;
11338
11339
1/2
✓ Branch 0 taken 28416 times.
✗ Branch 1 not taken.
28416 if(!p_igetw(&tmp, f))
11340 {
11341 return qe_invalid;
11342 }
11343
11344 28416 numsub = (int32_t)tmp;
11345 }
11346
11347 int32_t j;
11348
11349
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 75277 times.
✓ Branch 2 taken 46861 times.
✓ Branch 3 taken 28416 times.
75277 for(j=0; (j<MAXSUBSCREENITEMS&&j<numsub); j++)
11350 {
11351 46861 memset(temp_sub,0,sizeof(subscreen_object));
11352
11353
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46861 times.
46861 switch(g->objects[j].type)
11354 {
11355 case ssoTEXT:
11356 case ssoTEXTBOX:
11357 case ssoCURRENTITEMTEXT:
11358 case ssoCURRENTITEMCLASSTEXT:
11359 if(g->objects[j].dp1 != NULL) delete [](char *)g->objects[j].dp1;
11360
11361 //fall through
11362 default:
11363 46861 memset(&g->objects[j],0,sizeof(subscreen_object));
11364 46861 break;
11365 }
11366
11367
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_getc(&(temp_sub->type),f))
11368 return qe_invalid;
11369
11370
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_getc(&(temp_sub->pos),f))
11371 return qe_invalid;
11372
11373
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(s_version < 5)
11374 {
11375 switch(temp_sub->pos)
11376 {
11377 case 0:
11378 temp_sub->pos = sspUP | sspDOWN | sspSCROLLING;
11379 break;
11380
11381 case 1:
11382 temp_sub->pos = sspUP;
11383 break;
11384
11385 case 2:
11386 temp_sub->pos = sspDOWN;
11387 break;
11388
11389 default:
11390 temp_sub->pos = 0;
11391 }
11392 }
11393
11394
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_igetw(&(temp_sub->x),f))
11395 return qe_invalid;
11396
11397
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_igetw(&(temp_sub->y),f))
11398 return qe_invalid;
11399
11400
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_igetw(&(temp_sub->w),f))
11401 return qe_invalid;
11402
11403
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_igetw(&(temp_sub->h),f))
11404 return qe_invalid;
11405
11406
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_getc(&(temp_sub->colortype1),f))
11407 return qe_invalid;
11408
11409
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_igetw(&(temp_sub->color1),f))
11410 return qe_invalid;
11411
11412
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_getc(&(temp_sub->colortype2),f))
11413 return qe_invalid;
11414
11415
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_igetw(&(temp_sub->color2),f))
11416 return qe_invalid;
11417
11418
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_getc(&(temp_sub->colortype3),f))
11419 return qe_invalid;
11420
11421
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_igetw(&(temp_sub->color3),f))
11422 return qe_invalid;
11423
11424
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_igetd(&(temp_sub->d1),f))
11425 return qe_invalid;
11426
11427
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_igetd(&(temp_sub->d2),f))
11428 return qe_invalid;
11429
11430
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_igetd(&(temp_sub->d3),f))
11431 return qe_invalid;
11432
11433
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_igetd(&(temp_sub->d4),f))
11434 return qe_invalid;
11435
11436
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_igetd(&(temp_sub->d5),f))
11437 return qe_invalid;
11438
11439
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_igetd(&(temp_sub->d6),f))
11440 return qe_invalid;
11441
11442
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_igetd(&(temp_sub->d7),f))
11443 return qe_invalid;
11444
11445
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_igetd(&(temp_sub->d8),f))
11446 return qe_invalid;
11447
11448
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_igetd(&(temp_sub->d9),f))
11449 return qe_invalid;
11450
11451
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_igetd(&(temp_sub->d10),f))
11452 return qe_invalid;
11453
11454
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46861 times.
46861 if(s_version < 2)
11455 {
11456 if(!p_igetl(&(temp_sub->speed),f))
11457 return qe_invalid;
11458
11459 if(!p_igetl(&(temp_sub->delay),f))
11460 return qe_invalid;
11461
11462 if(!p_igetl(&(temp_sub->frame),f))
11463 return qe_invalid;
11464 }
11465 else
11466 {
11467
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_getc(&(temp_sub->speed),f))
11468 return qe_invalid;
11469
11470
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_getc(&(temp_sub->delay),f))
11471 return qe_invalid;
11472
11473
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_igetw(&(temp_sub->frame),f))
11474 return qe_invalid;
11475 }
11476
11477 46861 int32_t temp_size=0;
11478
11479 // bool deletets = false;
11480
4/4
✓ Branch 0 taken 20828 times.
✓ Branch 1 taken 3482 times.
✓ Branch 2 taken 22301 times.
✓ Branch 3 taken 250 times.
46861 switch(temp_sub->type)
11481 {
11482 case ssoTEXT:
11483 case ssoTEXTBOX:
11484 case ssoCURRENTITEMTEXT:
11485 case ssoCURRENTITEMCLASSTEXT:
11486 {
11487 word temptempsize;
11488
11489
1/2
✓ Branch 0 taken 3482 times.
✗ Branch 1 not taken.
3482 if(!p_igetw(&temptempsize,f))
11490 {
11491 return qe_invalid;
11492 }
11493
11494 //temptempsize = temp1 + (temp2 << 8);
11495 3482 temp_size = (int32_t)temptempsize;
11496 3482 uint32_t char_length = temp_size+2;
11497
1/2
✓ Branch 0 taken 3482 times.
✗ Branch 1 not taken.
3482 if (char_length > MAX_DP1_LEN)
11498 {
11499 return qe_invalid;
11500 }
11501 3482 tempdp1[char_length - 1] = '\0';
11502
11503
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3482 times.
3482 if(temp_size)
11504
1/2
✓ Branch 0 taken 3482 times.
✗ Branch 1 not taken.
3482 if(!pfread(tempdp1,temp_size+1,f))
11505 return qe_invalid;
11506 3482 break;
11507 }
11508
11509 case ssoLIFEMETER:
11510
1/2
✓ Branch 0 taken 250 times.
✗ Branch 1 not taken.
250 if(get_bit(deprecated_rules, 12) != 0) // qr_24HC
11511 temp_sub->d3 = 1;
11512
11513
1/2
✓ Branch 0 taken 250 times.
✗ Branch 1 not taken.
250 if(!p_getc(&(temp_sub->dp1),f))
11514 return qe_invalid;
11515
11516 250 break;
11517
11518
11519 case ssoCURRENTITEM:
11520
11521
1/2
✓ Branch 0 taken 20828 times.
✗ Branch 1 not taken.
20828 if(s_version < 6)
11522 {
11523 switch(temp_sub->d1)
11524 {
11525 case ssiBOMB:
11526 temp_sub->d1 = itype_bomb;
11527 break;
11528
11529 case ssiSWORD:
11530 temp_sub->d1 = itype_sword;
11531 break;
11532
11533 case ssiSHIELD:
11534 temp_sub->d1 = itype_shield;
11535 break;
11536
11537 case ssiCANDLE:
11538 temp_sub->d1 = itype_candle;
11539 break;
11540
11541 case ssiLETTER:
11542 temp_sub->d1 = itype_letter;
11543 break;
11544
11545 case ssiPOTION:
11546 temp_sub->d1 = itype_potion;
11547 break;
11548
11549 case ssiLETTERPOTION:
11550 temp_sub->d1 = itype_letterpotion;
11551 break;
11552
11553 case ssiBOW:
11554 temp_sub->d1 = itype_bow;
11555 break;
11556
11557 case ssiARROW:
11558 temp_sub->d1 = itype_arrow;
11559 break;
11560
11561 case ssiBOWANDARROW:
11562 temp_sub->d1 = itype_bowandarrow;
11563 break;
11564
11565 case ssiBAIT:
11566 temp_sub->d1 = itype_bait;
11567 break;
11568
11569 case ssiRING:
11570 temp_sub->d1 = itype_ring;
11571 break;
11572
11573 case ssiBRACELET:
11574 temp_sub->d1 = itype_bracelet;
11575 break;
11576
11577 case ssiMAP:
11578 temp_sub->d1 = itype_map;
11579 break;
11580
11581 case ssiCOMPASS:
11582 temp_sub->d1 = itype_compass;
11583 break;
11584
11585 case ssiBOSSKEY:
11586 temp_sub->d1 = itype_bosskey;
11587 break;
11588
11589 case ssiMAGICKEY:
11590 temp_sub->d1 = itype_magickey;
11591 break;
11592
11593 case ssiBRANG:
11594 temp_sub->d1 = itype_brang;
11595 break;
11596
11597 case ssiWAND:
11598 temp_sub->d1 = itype_wand;
11599 break;
11600
11601 case ssiRAFT:
11602 temp_sub->d1 = itype_raft;
11603 break;
11604
11605 case ssiLADDER:
11606 temp_sub->d1 = itype_ladder;
11607 break;
11608
11609 case ssiWHISTLE:
11610 temp_sub->d1 = itype_whistle;
11611 break;
11612
11613 case ssiBOOK:
11614 temp_sub->d1 = itype_book;
11615 break;
11616
11617 case ssiWALLET:
11618 temp_sub->d1 = itype_wallet;
11619 break;
11620
11621 case ssiSBOMB:
11622 temp_sub->d1 = itype_sbomb;
11623 break;
11624
11625 case ssiHCPIECE:
11626 temp_sub->d1 = itype_heartpiece;
11627 break;
11628
11629 case ssiAMULET:
11630 temp_sub->d1 = itype_amulet;
11631 break;
11632
11633 case ssiFLIPPERS:
11634 temp_sub->d1 = itype_flippers;
11635 break;
11636
11637 case ssiHOOKSHOT:
11638 temp_sub->d1 = itype_hookshot;
11639 break;
11640
11641 case ssiLENS:
11642 temp_sub->d1 = itype_lens;
11643 break;
11644
11645 case ssiHAMMER:
11646 temp_sub->d1 = itype_hammer;
11647 break;
11648
11649 case ssiBOOTS:
11650 temp_sub->d1 = itype_boots;
11651 break;
11652
11653 case ssiDIVINEFIRE:
11654 temp_sub->d1 = itype_divinefire;
11655 break;
11656
11657 case ssiDIVINEESCAPE:
11658 temp_sub->d1 = itype_divineescape;
11659 break;
11660
11661 case ssiDIVINEPROTECTION:
11662 temp_sub->d1 = itype_divineprotection;
11663 break;
11664
11665 case ssiQUIVER:
11666 temp_sub->d1 = itype_quiver;
11667 break;
11668
11669 case ssiBOMBBAG:
11670 temp_sub->d1 = itype_bombbag;
11671 break;
11672
11673 case ssiCBYRNA:
11674 temp_sub->d1 = itype_cbyrna;
11675 break;
11676
11677 case ssiROCS:
11678 temp_sub->d1 = itype_rocs;
11679 break;
11680
11681 case ssiHOVERBOOTS:
11682 temp_sub->d1 = itype_hoverboots;
11683 break;
11684
11685 case ssiSPINSCROLL:
11686 temp_sub->d1 = itype_spinscroll;
11687 break;
11688
11689 case ssiCROSSSCROLL:
11690 temp_sub->d1 = itype_crossscroll;
11691 break;
11692
11693 case ssiQUAKESCROLL:
11694 temp_sub->d1 = itype_quakescroll;
11695 break;
11696
11697 case ssiWHISPRING:
11698 temp_sub->d1 = itype_whispring;
11699 break;
11700
11701 case ssiCHARGERING:
11702 temp_sub->d1 = itype_chargering;
11703 break;
11704
11705 case ssiPERILSCROLL:
11706 temp_sub->d1 = itype_perilscroll;
11707 break;
11708
11709 case ssiWEALTHMEDAL:
11710 temp_sub->d1 = itype_wealthmedal;
11711 break;
11712
11713 case ssiHEARTRING:
11714 temp_sub->d1 = itype_heartring;
11715 break;
11716
11717 case ssiMAGICRING:
11718 temp_sub->d1 = itype_magicring;
11719 break;
11720
11721 case ssiSPINSCROLL2:
11722 temp_sub->d1 = itype_spinscroll2;
11723 break;
11724
11725 case ssiQUAKESCROLL2:
11726 temp_sub->d1 = itype_quakescroll2;
11727 break;
11728
11729 case ssiAGONY:
11730 temp_sub->d1 = itype_agony;
11731 break;
11732
11733 case ssiSTOMPBOOTS:
11734 temp_sub->d1 = itype_stompboots;
11735 break;
11736
11737 case ssiWHIMSICALRING:
11738 temp_sub->d1 = itype_whimsicalring;
11739 break;
11740
11741 case ssiPERILRING:
11742 temp_sub->d1 = itype_perilring;
11743 break;
11744
11745 default:
11746 temp_sub->d1 += itype_custom1 - ssiMAX;
11747 }
11748 }
11749
11750 //fall-through
11751 default:
11752
1/2
✓ Branch 0 taken 43129 times.
✗ Branch 1 not taken.
43129 if(!p_getc(&(temp_sub->dp1),f))
11753 return qe_invalid;
11754
11755 43129 break;
11756 }
11757
11758
2/2
✓ Branch 0 taken 8694 times.
✓ Branch 1 taken 38167 times.
46861 if(s_version < 7)
11759 {
11760
3/3
✓ Branch 0 taken 32010 times.
✓ Branch 1 taken 1389 times.
✓ Branch 2 taken 4768 times.
38167 switch(temp_sub->type)
11761 {
11762 case ssoMAGICGAUGE:
11763 {
11764
2/2
✓ Branch 0 taken 141 times.
✓ Branch 1 taken 1248 times.
1389 if(!temp_sub->d9)
11765 1248 temp_sub->d9 = -1; //-1 now represents 'always'
11766 1389 break;
11767 }
11768 case ssoLIFEGAUGE:
11769 4768 temp_sub->d9 = 0; //Unused, doesn't do anything? Clear it...
11770 4768 break;
11771 }
11772 38167 }
11773
11774
3/3
✓ Branch 0 taken 3482 times.
✓ Branch 1 taken 41785 times.
✓ Branch 2 taken 1594 times.
46861 switch(temp_sub->type)
11775 {
11776 case ssoTEXT:
11777 case ssoTEXTBOX:
11778 case ssoCURRENTITEMTEXT:
11779 case ssoCURRENTITEMCLASSTEXT:
11780
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3482 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3482 if(g->objects[j].dp1 != NULL) delete[](char *)g->objects[j].dp1;
11781
11782 3482 memcpy(&g->objects[j],temp_sub,sizeof(subscreen_object));
11783 3482 g->objects[j].dp1 = new char[temp_size+2];
11784 3482 strcpy((char*)g->objects[j].dp1,tempdp1);
11785 3482 break;
11786
11787 case ssoCOUNTER:
11788
1/2
✓ Branch 0 taken 1594 times.
✗ Branch 1 not taken.
1594 if(s_version<3)
11789 {
11790 temp_sub->d6=(temp_sub->d6?1:0)+(temp_sub->d8?2:0);
11791 temp_sub->d8=0;
11792 }
11793
11794 default:
11795 43379 memcpy(&g->objects[j],temp_sub,sizeof(subscreen_object));
11796 43379 break;
11797 }
11798
11799 46861 g->name[0] = '\0';
11800 46861 strncat(g->name, tempname, 64 - 1);
11801 46861 g->ss_type = temp_ss;
11802 46861 }
11803
11804
2/2
✓ Branch 0 taken 7227635 times.
✓ Branch 1 taken 28416 times.
7256051 for(j=numsub; j<MAXSUBSCREENITEMS; j++)
11805 {
11806 //clear all unused object in this subscreen -DD
11807
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7227635 times.
7227635 switch(g->objects[j].type)
11808 {
11809 case ssoTEXT:
11810 case ssoTEXTBOX:
11811 case ssoCURRENTITEMTEXT:
11812 case ssoCURRENTITEMCLASSTEXT:
11813 if(g->objects[j].dp1 != NULL) delete [](char *)g->objects[j].dp1;
11814
11815 //fall through
11816 default:
11817 7227635 memset(&g->objects[j],0,sizeof(subscreen_object));
11818 7227635 break;
11819 }
11820 7227635 }
11821
11822 28416 return 0;
11823 28416 }
11824
11825 395 int32_t readsubscreens(PACKFILE *f)
11826 {
11827 word s_version;
11828 dword dummy;
11829
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 395 times.
395 if(!p_igetw(&s_version,f))
11830 return qe_invalid;
11831 395 FFCore.quest_format[vSubscreen] = s_version;
11832
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 if(!read_deprecated_section_cversion(f))
11833 return qe_invalid;
11834
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 if(!p_igetl(&dummy,f)) //section size
11835 return qe_invalid;
11836
11837
2/2
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 173 times.
395 if(s_version < 8)
11838 222 return read_old_subscreens(f,s_version);
11839
11840 173 subscreens_active.clear();
11841 173 subscreens_passive.clear();
11842 173 subscreens_overlay.clear();
11843
11844 byte sz;
11845
1/2
✓ Branch 0 taken 173 times.
✗ Branch 1 not taken.
173 if(!p_getc(&sz,f))
11846 return qe_invalid;
11847
2/2
✓ Branch 0 taken 563 times.
✓ Branch 1 taken 173 times.
736 for(byte q = 0; q < sz; ++q)
11848 {
11849 563 ZCSubscreen& tmp = subscreens_active.emplace_back();
11850
1/2
✓ Branch 0 taken 563 times.
✗ Branch 1 not taken.
563 if (auto ret = tmp.read(f, s_version))
11851 return ret;
11852 563 }
11853
1/2
✓ Branch 0 taken 173 times.
✗ Branch 1 not taken.
173 if(!p_getc(&sz,f))
11854 return qe_invalid;
11855
2/2
✓ Branch 0 taken 654 times.
✓ Branch 1 taken 173 times.
827 for(byte q = 0; q < sz; ++q)
11856 {
11857 654 ZCSubscreen& tmp = subscreens_passive.emplace_back();
11858
1/2
✓ Branch 0 taken 654 times.
✗ Branch 1 not taken.
654 if (auto ret = tmp.read(f, s_version))
11859 return ret;
11860 654 }
11861
1/2
✓ Branch 0 taken 173 times.
✗ Branch 1 not taken.
173 if(!p_getc(&sz,f))
11862 return qe_invalid;
11863
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 173 times.
179 for(byte q = 0; q < sz; ++q)
11864 {
11865 6 ZCSubscreen& tmp = subscreens_overlay.emplace_back();
11866
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if (auto ret = tmp.read(f, s_version))
11867 return ret;
11868 6 }
11869 173 return 0;
11870 395 }
11871
11872 void reset_subscreen(subscreen_group *tempss)
11873 {
11874 for(int32_t i=0; i<MAXSUBSCREENITEMS; ++i)
11875 {
11876 switch(tempss->objects[i].type)
11877 {
11878 case ssoTEXT:
11879 case ssoTEXTBOX:
11880 case ssoCURRENTITEMTEXT:
11881 case ssoCURRENTITEMCLASSTEXT:
11882 if(tempss->objects[i].dp1 != NULL) delete [](char *)tempss->objects[i].dp1;
11883
11884 //fall through
11885 default:
11886 memset(&tempss->objects[i],0,sizeof(subscreen_object));
11887 break;
11888 }
11889 }
11890 }
11891
11892 116 void reset_subscreens()
11893 {
11894 116 subscreens_active.clear();
11895 116 subscreens_passive.clear();
11896 116 subscreens_overlay.clear();
11897 116 }
11898
11899 116 int32_t setupsubscreens()
11900 {
11901 116 reset_subscreens();
11902 //return 0;
11903
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 232 times.
348 for(int q = 0; q < 2; ++q)
11904 {
11905 232 subscreens_active.emplace_back();
11906 232 subscreens_passive.emplace_back();
11907 232 }
11908 116 int32_t tempsubscreen=subscr_mode;
11909
11910
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(tempsubscreen>=ssdtMAX)
11911 tempsubscreen=0;
11912
11913
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
✗ Branch 2 not taken.
116 switch(tempsubscreen)
11914 {
11915 case ssdtOLD:
11916 case ssdtNEWSUBSCR:
11917 case ssdtREV2:
11918 case ssdtBSZELDA:
11919 case ssdtBSZELDAMODIFIED:
11920 case ssdtBSZELDAENHANCED:
11921 case ssdtBSZELDACOMPLETE:
11922 {
11923 116 subscreens_active[0].load_old(default_subscreen_active[tempsubscreen][0]);
11924 116 subscreens_active[0].sub_type=sstACTIVE;
11925 116 subscreens_active[0].name = "Active Subscreen (Triforce)";
11926 116 subscreens_active[1].load_old(default_subscreen_active[tempsubscreen][1]);
11927 116 subscreens_active[1].sub_type=sstACTIVE;
11928 116 subscreens_active[1].name = "Active Subscreen (Dungeon Map)";
11929 116 subscreens_passive[0].load_old(default_subscreen_passive[tempsubscreen][0]);
11930 116 subscreens_passive[0].sub_type=sstPASSIVE;
11931 116 subscreens_passive[0].name = "Passive Subscreen (Magic)";
11932 116 subscreens_passive[1].load_old(default_subscreen_passive[tempsubscreen][1]);
11933 116 subscreens_passive[1].sub_type=sstPASSIVE;
11934 116 subscreens_passive[1].name = "Passive Subscreen (No Magic)";
11935 116 break;
11936 }
11937
11938 case ssdtZ3:
11939 {
11940 subscreens_active[0].load_old(z3_active_a);
11941 subscreens_active[0].sub_type=sstACTIVE;
11942 subscreens_active[1].load_old(z3_active_ab);
11943 subscreens_active[1].sub_type=sstACTIVE;
11944 subscreens_passive[0].load_old(z3_passive_a);
11945 subscreens_passive[0].sub_type=sstPASSIVE;
11946 subscreens_passive[1].load_old(z3_passive_ab);
11947 subscreens_passive[1].sub_type=sstPASSIVE;
11948 break;
11949 }
11950 }
11951 116 subscr_mode = ssdtMAX;
11952 116 return 0;
11953 }
11954
11955 extern std::vector<std::shared_ptr<zasm_script>> zasm_scripts;
11956
11957 extern script_data *ffscripts[NUMSCRIPTFFC];
11958 extern script_data *itemscripts[NUMSCRIPTITEM];
11959 extern script_data *guyscripts[NUMSCRIPTGUYS];
11960 extern script_data *lwpnscripts[NUMSCRIPTWEAPONS];
11961 extern script_data *ewpnscripts[NUMSCRIPTWEAPONS];
11962 extern script_data *globalscripts[NUMSCRIPTGLOBAL];
11963 extern script_data *genericscripts[NUMSCRIPTSGENERIC];
11964 extern script_data *playerscripts[NUMSCRIPTHERO];
11965 extern script_data *screenscripts[NUMSCRIPTSCREEN];
11966 extern script_data *dmapscripts[NUMSCRIPTSDMAP];
11967 extern script_data *itemspritescripts[NUMSCRIPTSITEMSPRITE];
11968 extern script_data *comboscripts[NUMSCRIPTSCOMBODATA];
11969 extern script_data *subscreenscripts[NUMSCRIPTSSUBSCREEN];
11970
11971 static std::vector<const script_data*> read_scripts;
11972
11973 421 static script_data fake_script_data(ScriptType::None, 0);
11974
11975 469 int32_t readffscript(PACKFILE *f, zquestheader *Header)
11976 {
11977 int32_t dummy;
11978 469 word s_version=0, zmeta_version=0;
11979 469 byte numscripts=0;
11980 469 numscripts=numscripts; //to avoid unused variables warnings
11981 int32_t ret;
11982 469 read_scripts.clear();
11983 469 zasm_scripts.clear();
11984
11985 //section version info
11986
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 469 times.
469 if(!p_igetw(&s_version,f))
11987 {
11988 return qe_invalid;
11989 }
11990
11991 469 FFCore.quest_format[vFFScript] = s_version;
11992
11993
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 if(!read_deprecated_section_cversion(f))
11994 {
11995 return qe_invalid;
11996 }
11997
11998
2/2
✓ Branch 0 taken 279 times.
✓ Branch 1 taken 190 times.
469 if(s_version >= 18)
11999 {
12000
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if(!p_igetw(&zmeta_version,f))
12001 {
12002 return qe_invalid;
12003 }
12004 190 }
12005
12006 //section size
12007
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 if(!p_igetl(&dummy,f))
12008 {
12009 return qe_invalid;
12010 }
12011
12012
2/2
✓ Branch 0 taken 245 times.
✓ Branch 1 taken 224 times.
469 if ( FFCore.quest_format[vLastCompile] < 13 ) FFCore.quest_format[vLastCompile] = s_version;
12013 469 al_trace("Loaded scripts last compiled in ZScript version: %d\n", (FFCore.quest_format[vLastCompile]));
12014
12015
2/2
✓ Branch 0 taken 281 times.
✓ Branch 1 taken 124 times.
469 if(s_version >= 27)
12016 {
12017 124 ret = read_quest_zasm(f, s_version);
12018
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
124 if(ret)
12019 return qe_invalid;
12020 124 }
12021
12022 //finally... section data
12023
2/2
✓ Branch 0 taken 202240 times.
✓ Branch 1 taken 405 times.
202645 for(int32_t i = 0; i < ((s_version < 2) ? NUMSCRIPTFFCOLD : NUMSCRIPTFFC); i++)
12024 {
12025 202240 ret = read_one_ffscript(f, Header, i, s_version, ffscripts[i], zmeta_version);
12026
12027
1/2
✓ Branch 0 taken 202240 times.
✗ Branch 1 not taken.
202240 if (ret)
12028 {
12029 return qe_invalid;
12030 }
12031 202240 }
12032
12033 /* HIGHLY UNORTHODOX UPDATING THING, by Deedee
12034 * This fixes changes to sprite jump values introduced in early 2.55 alphas.
12035 * Zoria didn't bump up the versions as liberally as he should have, but thankfully
12036 * there was a version bump a week before a change that broke stuff.
12037 */
12038
7/8
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 215 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 190 times.
✓ Branch 4 taken 190 times.
✓ Branch 5 taken 190 times.
✓ Branch 6 taken 190 times.
✓ Branch 7 taken 190 times.
405 if(((Header->zelda_version < 0x253)||((Header->zelda_version == 0x253)&&(Header->build<33))||((Header->zelda_version > 0x253) && s_version < 12)))
12039 {
12040 595 set_qr(qr_SPRITE_JUMP_IS_TRUNCATED,1);
12041 595 }
12042
2/2
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 205 times.
395 if(s_version < 19)
12043 {
12044 205 set_qr(qr_FLUCTUATING_ENEMY_JUMP,1);
12045 205 }
12046
12047
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 395 times.
395 if(s_version > 1)
12048 {
12049
2/2
✓ Branch 0 taken 101120 times.
✓ Branch 1 taken 395 times.
101515 for(int32_t i = 0; i < NUMSCRIPTITEM; i++)
12050 {
12051 101120 ret = read_one_ffscript(f, Header, i, s_version, itemscripts[i], zmeta_version);
12052
12053
1/2
✓ Branch 0 taken 101120 times.
✗ Branch 1 not taken.
101120 if (ret)
12054 {
12055 return qe_invalid;
12056 }
12057 101120 }
12058
12059
2/2
✓ Branch 0 taken 101120 times.
✓ Branch 1 taken 395 times.
101515 for(int32_t i = 0; i < NUMSCRIPTGUYS; i++)
12060 {
12061 101120 ret = read_one_ffscript(f, Header, i, s_version, guyscripts[i], zmeta_version);
12062
12063
1/2
✓ Branch 0 taken 101120 times.
✗ Branch 1 not taken.
101120 if (ret)
12064 {
12065 return qe_invalid;
12066 }
12067 101120 }
12068
12069
2/2
✓ Branch 0 taken 101120 times.
✓ Branch 1 taken 395 times.
101515 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12070 {
12071 101120 ret = read_one_ffscript(f, Header, i, s_version, &fake_script_data, zmeta_version);
12072
12073
1/2
✓ Branch 0 taken 101120 times.
✗ Branch 1 not taken.
101120 if (ret)
12074 {
12075 return qe_invalid;
12076 }
12077 101120 }
12078
12079
2/2
✓ Branch 0 taken 101120 times.
✓ Branch 1 taken 395 times.
101515 for(int32_t i = 0; i < NUMSCRIPTSCREEN; i++)
12080 {
12081 101120 ret = read_one_ffscript(f, Header, i, s_version, screenscripts[i], zmeta_version);
12082
12083
1/2
✓ Branch 0 taken 101120 times.
✗ Branch 1 not taken.
101120 if (ret)
12084 {
12085 return qe_invalid;
12086 }
12087 101120 }
12088
12089
2/2
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 205 times.
395 if(s_version > 16)
12090 {
12091
2/2
✓ Branch 0 taken 1520 times.
✓ Branch 1 taken 190 times.
1710 for(int32_t i = 0; i < NUMSCRIPTGLOBAL; ++i)
12092 {
12093 1520 ret = read_one_ffscript(f, Header, i, s_version, globalscripts[i], zmeta_version);
12094
12095
1/2
✓ Branch 0 taken 1520 times.
✗ Branch 1 not taken.
1520 if (ret)
12096 {
12097 return qe_invalid;
12098 }
12099 1520 }
12100 190 }
12101
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 205 times.
205 else if(s_version > 13)
12102 {
12103 for(int32_t i = 0; i < NUMSCRIPTGLOBAL255OLD; ++i)
12104 {
12105 ret = read_one_ffscript(f, Header, i, s_version, globalscripts[i], zmeta_version);
12106
12107 if (ret)
12108 {
12109 return qe_invalid;
12110 }
12111 }
12112
12113 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12114 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12115
12116 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONSAVE);
12117 }
12118
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 else if(s_version > 4)
12119 {
12120
2/2
✓ Branch 0 taken 820 times.
✓ Branch 1 taken 205 times.
1025 for(int32_t i = 0; i < NUMSCRIPTGLOBAL253; ++i)
12121 {
12122 820 ret = read_one_ffscript(f, Header, i, s_version, globalscripts[i], zmeta_version);
12123
12124
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if (ret)
12125 {
12126 return qe_invalid;
12127 }
12128 820 }
12129
12130
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 205 times.
205 if(globalscripts[GLOBAL_SCRIPT_ONLAUNCH] != NULL)
12131
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 delete globalscripts[GLOBAL_SCRIPT_ONLAUNCH];
12132
12133
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 globalscripts[GLOBAL_SCRIPT_ONLAUNCH] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONLAUNCH);
12134
12135
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 205 times.
205 if(globalscripts[GLOBAL_SCRIPT_ONCONTGAME] != NULL)
12136
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 delete globalscripts[GLOBAL_SCRIPT_ONCONTGAME];
12137
12138
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 globalscripts[GLOBAL_SCRIPT_ONCONTGAME] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONCONTGAME);
12139
12140
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 205 times.
205 if(globalscripts[GLOBAL_SCRIPT_F6] != NULL)
12141
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 delete globalscripts[GLOBAL_SCRIPT_F6];
12142
12143
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 globalscripts[GLOBAL_SCRIPT_F6] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_F6);
12144
12145
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 205 times.
205 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12146
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12147
12148
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONSAVE);
12149 205 }
12150 else
12151 {
12152 for(int32_t i = 0; i < NUMSCRIPTGLOBALOLD; i++)
12153 {
12154 ret = read_one_ffscript(f, Header, i, s_version, globalscripts[i], zmeta_version);
12155
12156 if (ret)
12157 {
12158 return qe_invalid;
12159 }
12160 }
12161
12162 if(globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] != NULL)
12163 delete globalscripts[GLOBAL_SCRIPT_ONSAVELOAD];
12164
12165 globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONSAVELOAD);
12166
12167 if(globalscripts[GLOBAL_SCRIPT_ONLAUNCH] != NULL)
12168 delete globalscripts[GLOBAL_SCRIPT_ONLAUNCH];
12169
12170 globalscripts[GLOBAL_SCRIPT_ONLAUNCH] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONLAUNCH);
12171
12172 if(globalscripts[GLOBAL_SCRIPT_ONCONTGAME] != NULL)
12173 delete globalscripts[GLOBAL_SCRIPT_ONCONTGAME];
12174
12175 globalscripts[GLOBAL_SCRIPT_ONCONTGAME] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONCONTGAME);
12176
12177 if(globalscripts[GLOBAL_SCRIPT_F6] != NULL)
12178 delete globalscripts[GLOBAL_SCRIPT_F6];
12179
12180 globalscripts[GLOBAL_SCRIPT_F6] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_F6);
12181
12182 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12183 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12184
12185 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONSAVE);
12186 }
12187
12188
2/2
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 205 times.
395 if(s_version > 10) //expanded the number of Hero scripts to 5.
12189 {
12190
2/2
✓ Branch 0 taken 950 times.
✓ Branch 1 taken 190 times.
1140 for(int32_t i = 0; i < NUMSCRIPTHERO; i++)
12191 {
12192 950 ret = read_one_ffscript(f, Header, i, s_version, playerscripts[i], zmeta_version);
12193
12194
1/2
✓ Branch 0 taken 950 times.
✗ Branch 1 not taken.
950 if (ret)
12195 {
12196 return qe_invalid;
12197 }
12198 950 }
12199 190 }
12200 else
12201 {
12202
2/2
✓ Branch 0 taken 615 times.
✓ Branch 1 taken 205 times.
820 for(int32_t i = 0; i < NUMSCRIPTHEROOLD; i++)
12203 {
12204 615 ret = read_one_ffscript(f, Header, i, s_version, playerscripts[i], zmeta_version);
12205
12206
1/2
✓ Branch 0 taken 615 times.
✗ Branch 1 not taken.
615 if (ret)
12207 {
12208 return qe_invalid;
12209 }
12210 615 }
12211
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 if(playerscripts[3] != NULL)
12212
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 delete playerscripts[3];
12213
12214
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 playerscripts[3] = new script_data(ScriptType::Hero, 3);
12215
12216
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 if(playerscripts[4] != NULL)
12217
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 205 times.
205 delete playerscripts[4];
12218
12219
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 playerscripts[4] = new script_data(ScriptType::Hero, 4);
12220 }
12221
3/4
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 205 times.
✓ Branch 2 taken 190 times.
✗ Branch 3 not taken.
395 if(s_version > 8 && s_version < 10)
12222 {
12223
12224 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12225 {
12226 ret = read_one_ffscript(f, Header, i, s_version, ewpnscripts[i], zmeta_version);
12227
12228 if (ret)
12229 {
12230 return qe_invalid;
12231 }
12232 }
12233 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12234 {
12235 ret = read_one_ffscript(f, Header, i, s_version, dmapscripts[i], zmeta_version);
12236
12237 if (ret)
12238 {
12239 return qe_invalid;
12240 }
12241 }
12242
12243 }
12244
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 190 times.
395 if(s_version >= 10)
12245 {
12246
2/2
✓ Branch 0 taken 48640 times.
✓ Branch 1 taken 190 times.
48830 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12247 {
12248 48640 ret = read_one_ffscript(f, Header, i, s_version, lwpnscripts[i], zmeta_version);
12249
12250
1/2
✓ Branch 0 taken 48640 times.
✗ Branch 1 not taken.
48640 if (ret)
12251 {
12252 return qe_invalid;
12253 }
12254 48640 }
12255
2/2
✓ Branch 0 taken 48640 times.
✓ Branch 1 taken 190 times.
48830 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12256 {
12257 48640 ret = read_one_ffscript(f, Header, i, s_version, ewpnscripts[i], zmeta_version);
12258
12259
1/2
✓ Branch 0 taken 48640 times.
✗ Branch 1 not taken.
48640 if (ret)
12260 {
12261 return qe_invalid;
12262 }
12263 48640 }
12264
2/2
✓ Branch 0 taken 48640 times.
✓ Branch 1 taken 190 times.
48830 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12265 {
12266 48640 ret = read_one_ffscript(f, Header, i, s_version, dmapscripts[i], zmeta_version);
12267
12268
1/2
✓ Branch 0 taken 48640 times.
✗ Branch 1 not taken.
48640 if (ret)
12269 {
12270 return qe_invalid;
12271 }
12272 48640 }
12273
12274 190 }
12275
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 190 times.
395 if(s_version >=12)
12276 {
12277
2/2
✓ Branch 0 taken 48640 times.
✓ Branch 1 taken 190 times.
48830 for(int32_t i = 0; i < NUMSCRIPTSITEMSPRITE; i++)
12278 {
12279 48640 ret = read_one_ffscript(f, Header, i, s_version, itemspritescripts[i], zmeta_version);
12280
12281
1/2
✓ Branch 0 taken 48640 times.
✗ Branch 1 not taken.
48640 if (ret)
12282 {
12283 return qe_invalid;
12284 }
12285 48640 }
12286 190 }
12287
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 190 times.
395 if(s_version >=15)
12288 {
12289
2/2
✓ Branch 0 taken 97280 times.
✓ Branch 1 taken 190 times.
97470 for(int32_t i = 0; i < NUMSCRIPTSCOMBODATA; i++)
12290 {
12291 97280 ret = read_one_ffscript(f, Header, i, s_version, comboscripts[i], zmeta_version);
12292
12293
1/2
✓ Branch 0 taken 97280 times.
✗ Branch 1 not taken.
97280 if (ret)
12294 {
12295 return qe_invalid;
12296 }
12297 97280 }
12298 190 }
12299
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 190 times.
395 if(s_version >19)
12300 {
12301 190 word numgenscripts = NUMSCRIPTSGENERIC;
12302
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if(!p_igetw(&numgenscripts,f))
12303 {
12304 return qe_invalid;
12305 }
12306
2/2
✓ Branch 0 taken 97280 times.
✓ Branch 1 taken 190 times.
97470 for(int32_t i = 0; i < numgenscripts; i++)
12307 {
12308 97280 ret = read_one_ffscript(f, Header, i, s_version, genericscripts[i], zmeta_version);
12309
12310
1/2
✓ Branch 0 taken 97280 times.
✗ Branch 1 not taken.
97280 if (ret)
12311 {
12312 return qe_invalid;
12313 }
12314 97280 }
12315 190 }
12316
2/2
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 173 times.
395 if(s_version >21)
12317 {
12318 173 word numsubscripts = NUMSCRIPTSSUBSCREEN;
12319
1/2
✓ Branch 0 taken 173 times.
✗ Branch 1 not taken.
173 if(!p_igetw(&numsubscripts,f))
12320 {
12321 return qe_invalid;
12322 }
12323
2/2
✓ Branch 0 taken 44288 times.
✓ Branch 1 taken 173 times.
44461 for(int32_t i = 0; i < numsubscripts; i++)
12324 {
12325 44288 ret = read_one_ffscript(f, Header, i, s_version, subscreenscripts[i], zmeta_version);
12326
12327
1/2
✓ Branch 0 taken 44288 times.
✗ Branch 1 not taken.
44288 if (ret)
12328 {
12329 return qe_invalid;
12330 }
12331 44288 }
12332 173 }
12333 395 }
12334
12335
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 395 times.
395 if(s_version > 2)
12336 {
12337 int32_t bufsize;
12338 395 p_igetl(&bufsize, f);
12339
2/4
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 395 times.
395 if (bufsize < 0 || bufsize > 1024*1024*10)
12340 {
12341 // God help anyone storing more than 10MB of code in the script buffer.
12342 return qe_invalid;
12343 }
12344 395 char * buf = new char[bufsize+1];
12345 395 pfread(buf, bufsize, f);
12346 395 buf[bufsize]=0;
12347
12348
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 zScript = string(buf);
12349
12350
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 395 times.
395 delete[] buf;
12351 word numffcbindings;
12352 395 p_igetw(&numffcbindings, f);
12353
12354
2/2
✓ Branch 0 taken 10438 times.
✓ Branch 1 taken 395 times.
10833 for(int32_t i=0; i<numffcbindings; i++)
12355 {
12356 word id;
12357 10438 p_igetw(&id, f);
12358 10438 p_igetl(&bufsize, f);
12359
2/4
✓ Branch 0 taken 10438 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 10438 times.
10438 if (bufsize < 0 || bufsize > 1024)
12360 return qe_invalid;
12361 10438 buf = new char[bufsize+1];
12362 10438 pfread(buf, bufsize, f);
12363 10438 buf[bufsize]=0;
12364
12365 //fix for buggy older saved quests -DD
12366
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10438 times.
10438 if(id < NUMSCRIPTFFC-1)
12367 10438 ffcmap[id].scriptname = buf;
12368
12369
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10438 times.
10438 delete[] buf;
12370 10438 }
12371
12372 word numglobalbindings;
12373 395 p_igetw(&numglobalbindings, f);
12374
12375
2/2
✓ Branch 0 taken 1594 times.
✓ Branch 1 taken 395 times.
1989 for(int32_t i=0; i<numglobalbindings; i++)
12376 {
12377 word id;
12378 1594 p_igetw(&id, f);
12379 1594 p_igetl(&bufsize, f);
12380
2/4
✓ Branch 0 taken 1594 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1594 times.
✗ Branch 3 not taken.
1594 if (bufsize < 0 || bufsize > 1024)
12381 return qe_invalid;
12382 1594 buf = new char[bufsize+1];
12383 1594 pfread(buf, bufsize, f);
12384 1594 buf[bufsize]=0;
12385
12386 // id in principle should be valid, since slot assignment cannot assign a global script to a bogus slot.
12387 // However, because of a corruption bug, some 2.50.x quests contain bogus entries in the global bindings table.
12388 // Ignore these. -DD
12389
2/2
✓ Branch 0 taken 558 times.
✓ Branch 1 taken 1036 times.
1594 if (id < NUMSCRIPTGLOBAL)
12390 {
12391 //Disable old '~Continue's, they'd wreak havoc. Bit messy, apologies ~Joe
12392
1/2
✓ Branch 0 taken 1036 times.
✗ Branch 1 not taken.
1036 if(strcmp(buf,"~Continue") == 0)
12393 {
12394 globalmap[id].scriptname = "";
12395
12396 if(globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] != NULL)
12397 globalscripts[GLOBAL_SCRIPT_ONSAVELOAD]->disable();
12398 }
12399 else
12400 {
12401 1036 globalmap[id].scriptname = buf;
12402 }
12403 1036 }
12404
12405
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1594 times.
1594 delete[] buf;
12406 1594 }
12407
12408
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 395 times.
395 if(s_version > 3)
12409 {
12410 word numitembindings;
12411 395 p_igetw(&numitembindings, f);
12412
12413
2/2
✓ Branch 0 taken 1306 times.
✓ Branch 1 taken 395 times.
1701 for(int32_t i=0; i<numitembindings; i++)
12414 {
12415 word id;
12416 1306 p_igetw(&id, f);
12417 1306 p_igetl(&bufsize, f);
12418
2/4
✓ Branch 0 taken 1306 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1306 times.
1306 if (bufsize < 0 || bufsize > 1024)
12419 return qe_invalid;
12420 1306 buf = new char[bufsize+1];
12421 1306 pfread(buf, bufsize, f);
12422 1306 buf[bufsize]=0;
12423
12424 //fix this too
12425
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1306 times.
1306 if(id <NUMSCRIPTITEM-1)
12426 1306 itemmap[id].scriptname = buf;
12427
12428
1/2
✓ Branch 0 taken 1306 times.
✗ Branch 1 not taken.
1306 delete[] buf;
12429 1306 }
12430 395 }
12431 //(v9+)
12432
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 190 times.
395 if(s_version > 8)
12433 {
12434 //npc scripts
12435 word numnpcbindings;
12436 190 p_igetw(&numnpcbindings, f);
12437
12438
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 190 times.
222 for(int32_t i=0; i<numnpcbindings; i++)
12439 {
12440 word id;
12441 32 p_igetw(&id, f);
12442 32 p_igetl(&bufsize, f);
12443
2/4
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 32 times.
✗ Branch 3 not taken.
32 if (bufsize < 0 || bufsize > 1024)
12444 return qe_invalid;
12445 32 buf = new char[bufsize+1];
12446 32 pfread(buf, bufsize, f);
12447 32 buf[bufsize]=0;
12448
12449 //fix this too
12450
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(id <NUMSCRIPTGUYS-1)
12451 32 npcmap[id].scriptname = buf;
12452
12453
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 delete[] buf;
12454 32 }
12455 //lweapon
12456 word numlwpnbindings;
12457 190 p_igetw(&numlwpnbindings, f);
12458
12459
2/2
✓ Branch 0 taken 331 times.
✓ Branch 1 taken 190 times.
521 for(int32_t i=0; i<numlwpnbindings; i++)
12460 {
12461 word id;
12462 331 p_igetw(&id, f);
12463 331 p_igetl(&bufsize, f);
12464
2/4
✓ Branch 0 taken 331 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 331 times.
331 if (bufsize < 0 || bufsize > 1024)
12465 return qe_invalid;
12466 331 buf = new char[bufsize+1];
12467 331 pfread(buf, bufsize, f);
12468 331 buf[bufsize]=0;
12469
12470 //fix this too
12471
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 331 times.
331 if(id <NUMSCRIPTWEAPONS-1)
12472 331 lwpnmap[id].scriptname = buf;
12473
12474
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 331 times.
331 delete[] buf;
12475 331 }
12476 //eweapon
12477 word numewpnbindings;
12478 190 p_igetw(&numewpnbindings, f);
12479
12480
2/2
✓ Branch 0 taken 297 times.
✓ Branch 1 taken 190 times.
487 for(int32_t i=0; i<numewpnbindings; i++)
12481 {
12482 word id;
12483 297 p_igetw(&id, f);
12484 297 p_igetl(&bufsize, f);
12485
2/4
✓ Branch 0 taken 297 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 297 times.
✗ Branch 3 not taken.
297 if (bufsize < 0 || bufsize > 1024)
12486 return qe_invalid;
12487 297 buf = new char[bufsize+1];
12488 297 pfread(buf, bufsize, f);
12489 297 buf[bufsize]=0;
12490
12491 //fix this too
12492
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 297 times.
297 if(id <NUMSCRIPTWEAPONS-1)
12493 297 ewpnmap[id].scriptname = buf;
12494
12495
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 297 times.
297 delete[] buf;
12496 297 }
12497 //hero
12498 word numherobindings;
12499 190 p_igetw(&numherobindings, f);
12500
12501
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 190 times.
213 for(int32_t i=0; i<numherobindings; i++)
12502 {
12503 word id;
12504 23 p_igetw(&id, f);
12505 23 p_igetl(&bufsize, f);
12506
2/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 23 times.
23 if (bufsize < 0 || bufsize > 1024)
12507 return qe_invalid;
12508 23 buf = new char[bufsize+1];
12509 23 pfread(buf, bufsize, f);
12510 23 buf[bufsize]=0;
12511
12512 //fix this too
12513
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
23 if(id <NUMSCRIPTHERO-1)
12514 23 playermap[id].scriptname = buf;
12515
12516
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 delete[] buf;
12517 23 }
12518 //dmaps
12519 word numdmapbindings;
12520 190 p_igetw(&numdmapbindings, f);
12521
12522
2/2
✓ Branch 0 taken 435 times.
✓ Branch 1 taken 190 times.
625 for(int32_t i=0; i<numdmapbindings; i++)
12523 {
12524 word id;
12525 435 p_igetw(&id, f);
12526 435 p_igetl(&bufsize, f);
12527
2/4
✓ Branch 0 taken 435 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 435 times.
435 if (bufsize < 0 || bufsize > 1024)
12528 return qe_invalid;
12529 435 buf = new char[bufsize+1];
12530 435 pfread(buf, bufsize, f);
12531 435 buf[bufsize]=0;
12532
12533 //fix this too
12534
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 435 times.
435 if(id <NUMSCRIPTSDMAP-1)
12535 435 dmapmap[id].scriptname = buf;
12536
12537
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 435 times.
435 delete[] buf;
12538 435 }
12539 //screen
12540 word numscreenbindings;
12541 190 p_igetw(&numscreenbindings, f);
12542
12543
2/2
✓ Branch 0 taken 413 times.
✓ Branch 1 taken 190 times.
603 for(int32_t i=0; i<numscreenbindings; i++)
12544 {
12545 word id;
12546 413 p_igetw(&id, f);
12547 413 p_igetl(&bufsize, f);
12548
2/4
✓ Branch 0 taken 413 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 413 times.
✗ Branch 3 not taken.
413 if (bufsize < 0 || bufsize > 1024)
12549 return qe_invalid;
12550 413 buf = new char[bufsize+1];
12551 413 pfread(buf, bufsize, f);
12552 413 buf[bufsize]=0;
12553
12554 //fix this too
12555
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 413 times.
413 if(id <NUMSCRIPTSDMAP-1)
12556 413 screenmap[id].scriptname = buf;
12557
12558
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 413 times.
413 delete[] buf;
12559 413 }
12560 190 }
12561
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 190 times.
395 if(s_version > 11)
12562 {
12563 word numspritebindings;
12564 190 p_igetw(&numspritebindings, f);
12565
12566
2/2
✓ Branch 0 taken 49 times.
✓ Branch 1 taken 190 times.
239 for(int32_t i=0; i<numspritebindings; i++)
12567 {
12568 word id;
12569 49 p_igetw(&id, f);
12570 49 p_igetl(&bufsize, f);
12571
2/4
✓ Branch 0 taken 49 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 49 times.
49 if (bufsize < 0 || bufsize > 1024)
12572 return qe_invalid;
12573 49 buf = new char[bufsize+1];
12574 49 pfread(buf, bufsize, f);
12575 49 buf[bufsize]=0;
12576
12577 //fix this too
12578
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49 times.
49 if(id <NUMSCRIPTSDMAP-1)
12579 49 itemspritemap[id].scriptname = buf;
12580
12581
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49 times.
49 delete[] buf;
12582 49 }
12583 190 }
12584
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 190 times.
395 if(s_version >= 15)
12585 {
12586 word numcombobindings;
12587 190 p_igetw(&numcombobindings, f);
12588
12589
2/2
✓ Branch 0 taken 157 times.
✓ Branch 1 taken 190 times.
347 for(int32_t i=0; i<numcombobindings; i++)
12590 {
12591 word id;
12592 157 p_igetw(&id, f);
12593 157 p_igetl(&bufsize, f);
12594
2/4
✓ Branch 0 taken 157 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 157 times.
✗ Branch 3 not taken.
157 if (bufsize < 0 || bufsize > 1024)
12595 return qe_invalid;
12596 157 buf = new char[bufsize+1];
12597 157 pfread(buf, bufsize, f);
12598 157 buf[bufsize]=0;
12599
12600 //fix this too
12601
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 157 times.
157 if(id <NUMSCRIPTSCOMBODATA-1)
12602 157 comboscriptmap[id].scriptname = buf;
12603
12604
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 157 times.
157 delete[] buf;
12605 157 }
12606 190 }
12607
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 190 times.
395 if(s_version > 19)
12608 {
12609 word numgenericbindings;
12610 190 p_igetw(&numgenericbindings, f);
12611
12612
2/2
✓ Branch 0 taken 1648 times.
✓ Branch 1 taken 190 times.
1838 for(int32_t i=0; i<numgenericbindings; i++)
12613 {
12614 word id;
12615 1648 p_igetw(&id, f);
12616 1648 p_igetl(&bufsize, f);
12617
2/4
✓ Branch 0 taken 1648 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1648 times.
✗ Branch 3 not taken.
1648 if (bufsize < 0 || bufsize > 1024)
12618 return qe_invalid;
12619 1648 buf = new char[bufsize+1];
12620 1648 pfread(buf, bufsize, f);
12621 1648 buf[bufsize]=0;
12622
12623 //fix this too
12624
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1648 times.
1648 if(id <NUMSCRIPTSGENERIC-1)
12625 1648 genericmap[id].scriptname = buf;
12626
12627
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1648 times.
1648 delete[] buf;
12628 1648 }
12629 190 }
12630
2/2
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 173 times.
395 if(s_version > 21)
12631 {
12632 word numsubscreenbindings;
12633 173 p_igetw(&numsubscreenbindings, f);
12634
12635
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 173 times.
181 for(int32_t i=0; i<numsubscreenbindings; i++)
12636 {
12637 word id;
12638 8 p_igetw(&id, f);
12639 8 p_igetl(&bufsize, f);
12640
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 if (bufsize < 0 || bufsize > 1024)
12641 return qe_invalid;
12642 8 buf = new char[bufsize+1];
12643 8 pfread(buf, bufsize, f);
12644 8 buf[bufsize]=0;
12645
12646 //fix this too
12647
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(id <NUMSCRIPTSSUBSCREEN-1)
12648 8 subscreenmap[id].scriptname = buf;
12649
12650
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 delete[] buf;
12651 8 }
12652 173 }
12653 395 }
12654
12655 // Set ZScriptVersion to the value encoded in the script's meta.ffscript_v.
12656 // This is only updated when the scripts have been recompiled.
12657 // They should all match each other.
12658 395 std::optional<word> zscript_version;
12659
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 190 times.
395 if (s_version >= 16)
12660 {
12661
2/2
✓ Branch 0 taken 188 times.
✓ Branch 1 taken 6589 times.
6777 for (auto script : read_scripts)
12662 {
12663
2/2
✓ Branch 0 taken 6587 times.
✓ Branch 1 taken 2 times.
6589 if (script->meta.ffscript_v == 0)
12664 {
12665 // These scripts were saved in a version prior to this field being set.
12666 // See https://discord.com/channels/876899628556091432/1368485306394738718
12667 2 zscript_version = 16;
12668 2 break;
12669 }
12670
1/2
✓ Branch 0 taken 6587 times.
✗ Branch 1 not taken.
6587 if (script->meta.ffscript_v > s_version)
12671 break;
12672
12673
2/2
✓ Branch 0 taken 6416 times.
✓ Branch 1 taken 171 times.
6587 if (!zscript_version.has_value())
12674 {
12675 171 zscript_version = script->meta.ffscript_v;
12676 171 continue;
12677 }
12678
12679
1/2
✓ Branch 0 taken 6416 times.
✗ Branch 1 not taken.
6416 if (zscript_version.value() != script->meta.ffscript_v)
12680 {
12681 zscript_version.reset();
12682 break;
12683 }
12684 }
12685
12686
2/2
✓ Branch 0 taken 173 times.
✓ Branch 1 taken 17 times.
190 if (!zscript_version.has_value())
12687 17 al_trace("WARNING: Setting zscript version to section version as fallback.\n");
12688 190 }
12689 395 setZScriptVersion(zscript_version.value_or(s_version));
12690 395 read_scripts.clear();
12691
12692 395 return 0;
12693 395 }
12694
12695 void(*reset_scripts_hook)();
12696
12697 477 void reset_scripts()
12698 {
12699 // We can't modify the script data while jit threads are possibly compiling them.
12700
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 466 times.
477 if (reset_scripts_hook)
12701 466 reset_scripts_hook();
12702
12703
2/2
✓ Branch 0 taken 244224 times.
✓ Branch 1 taken 477 times.
244701 for(int32_t i=0; i<NUMSCRIPTSGENERIC; i++)
12704 {
12705
1/2
✓ Branch 0 taken 244224 times.
✗ Branch 1 not taken.
244224 if (genericscripts[i]!=NULL) genericscripts[i]->disable();
12706 else genericscripts[i] = new script_data({ScriptType::Generic, i});
12707 244224 }
12708
12709
2/2
✓ Branch 0 taken 244224 times.
✓ Branch 1 taken 477 times.
244701 for(int32_t i=0; i<NUMSCRIPTFFC; i++)
12710 {
12711
1/2
✓ Branch 0 taken 244224 times.
✗ Branch 1 not taken.
244224 if (ffscripts[i])
12712 244224 ffscripts[i]->disable();
12713 else
12714 ffscripts[i] = new script_data(ScriptType::FFC, i);
12715 244224 }
12716
12717
2/2
✓ Branch 0 taken 122112 times.
✓ Branch 1 taken 477 times.
122589 for(int32_t i=0; i<NUMSCRIPTITEM; i++)
12718 {
12719
1/2
✓ Branch 0 taken 122112 times.
✗ Branch 1 not taken.
122112 if (itemscripts[i])
12720 122112 itemscripts[i]->disable();
12721 else
12722 itemscripts[i] = new script_data(ScriptType::Item, i);
12723 122112 }
12724
12725
2/2
✓ Branch 0 taken 122112 times.
✓ Branch 1 taken 477 times.
122589 for(int32_t i=0; i<NUMSCRIPTGUYS; i++)
12726 {
12727
1/2
✓ Branch 0 taken 122112 times.
✗ Branch 1 not taken.
122112 if (guyscripts[i])
12728 122112 guyscripts[i]->disable();
12729 else
12730 guyscripts[i] = new script_data(ScriptType::NPC, i);
12731 122112 }
12732
12733
2/2
✓ Branch 0 taken 122112 times.
✓ Branch 1 taken 477 times.
122589 for(int32_t i=0; i<NUMSCRIPTSCREEN; i++)
12734 {
12735
1/2
✓ Branch 0 taken 122112 times.
✗ Branch 1 not taken.
122112 if (screenscripts[i])
12736 122112 screenscripts[i]->disable();
12737 else
12738 screenscripts[i] = new script_data(ScriptType::Screen, i);
12739 122112 }
12740
12741
2/2
✓ Branch 0 taken 3816 times.
✓ Branch 1 taken 477 times.
4293 for(int32_t i=0; i<NUMSCRIPTGLOBAL; i++)
12742 {
12743
1/2
✓ Branch 0 taken 3816 times.
✗ Branch 1 not taken.
3816 if (globalscripts[i])
12744 3816 globalscripts[i]->disable();
12745 else
12746 globalscripts[i] = new script_data(ScriptType::Global, i);
12747 3816 }
12748
12749
2/2
✓ Branch 0 taken 2385 times.
✓ Branch 1 taken 477 times.
2862 for(int32_t i=0; i<NUMSCRIPTHERO; i++)
12750 {
12751
1/2
✓ Branch 0 taken 2385 times.
✗ Branch 1 not taken.
2385 if (playerscripts[i])
12752 2385 playerscripts[i]->disable();
12753 else
12754 playerscripts[i] = new script_data(ScriptType::Hero, i);
12755 2385 }
12756
12757
2/2
✓ Branch 0 taken 122112 times.
✓ Branch 1 taken 477 times.
122589 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
12758 {
12759
1/2
✓ Branch 0 taken 122112 times.
✗ Branch 1 not taken.
122112 if (lwpnscripts[i])
12760 122112 lwpnscripts[i]->disable();
12761 else
12762 lwpnscripts[i] = new script_data(ScriptType::Lwpn, i);
12763 122112 }
12764
2/2
✓ Branch 0 taken 122112 times.
✓ Branch 1 taken 477 times.
122589 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
12765 {
12766
1/2
✓ Branch 0 taken 122112 times.
✗ Branch 1 not taken.
122112 if (ewpnscripts[i])
12767 122112 ewpnscripts[i]->disable();
12768 else
12769 ewpnscripts[i] = new script_data(ScriptType::Ewpn, i);
12770 122112 }
12771
12772
2/2
✓ Branch 0 taken 122112 times.
✓ Branch 1 taken 477 times.
122589 for(int32_t i=0; i<NUMSCRIPTSDMAP; i++)
12773 {
12774
1/2
✓ Branch 0 taken 122112 times.
✗ Branch 1 not taken.
122112 if (dmapscripts[i])
12775 122112 dmapscripts[i]->disable();
12776 else
12777 dmapscripts[i] = new script_data(ScriptType::DMap, i);
12778 122112 }
12779
2/2
✓ Branch 0 taken 122112 times.
✓ Branch 1 taken 477 times.
122589 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE; i++)
12780 {
12781
1/2
✓ Branch 0 taken 122112 times.
✗ Branch 1 not taken.
122112 if (itemspritescripts[i])
12782 122112 itemspritescripts[i]->disable();
12783 else
12784 itemspritescripts[i] = new script_data(ScriptType::ItemSprite, i);
12785 122112 }
12786
2/2
✓ Branch 0 taken 244224 times.
✓ Branch 1 taken 477 times.
244701 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA; i++)
12787 {
12788
1/2
✓ Branch 0 taken 244224 times.
✗ Branch 1 not taken.
244224 if (comboscripts[i])
12789 244224 comboscripts[i]->disable();
12790 else
12791 comboscripts[i] = new script_data(ScriptType::Combo, i);
12792 244224 }
12793
2/2
✓ Branch 0 taken 477 times.
✓ Branch 1 taken 122112 times.
122589 for(int32_t i=0; i<NUMSCRIPTSSUBSCREEN; i++)
12794 {
12795
1/2
✓ Branch 0 taken 122112 times.
✗ Branch 1 not taken.
122112 if (subscreenscripts[i])
12796 122112 subscreenscripts[i]->disable();
12797 else
12798 subscreenscripts[i] = new script_data(ScriptType::EngineSubscreen, i);
12799 122112 }
12800 477 }
12801
12802 // 3.0+ calls this.
12803 124 int32_t read_quest_zasm(PACKFILE *f, word s_version)
12804 {
12805 int32_t num_commands;
12806
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
124 if(!p_igetl(&num_commands,f))
12807 return qe_invalid;
12808 #ifdef ZC_FUZZ
12809 const int32_t command_limit = 300000;
12810 #else
12811 124 const int32_t command_limit = 25000000;
12812 #endif
12813
2/4
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 124 times.
124 if (num_commands < 0 || num_commands > command_limit)
12814 return qe_invalid;
12815
12816 124 std::vector<ffscript> zasm;
12817
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 zasm.reserve(num_commands);
12818
2/2
✓ Branch 0 taken 3132409 times.
✓ Branch 1 taken 124 times.
3132533 for(int32_t j=0; j<num_commands; j++)
12819 {
12820
1/2
✓ Branch 0 taken 3132409 times.
✗ Branch 1 not taken.
3132409 ffscript temp_script;
12821
2/4
✓ Branch 0 taken 3132409 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3132409 times.
✗ Branch 3 not taken.
3132409 if(!p_igetw(&(temp_script.command),f))
12822 return qe_invalid;
12823
12824
2/4
✓ Branch 0 taken 3132409 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3132409 times.
✗ Branch 3 not taken.
3132409 if(!p_igetl(&(temp_script.arg1),f))
12825 return qe_invalid;
12826
12827
2/4
✓ Branch 0 taken 3132409 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3132409 times.
✗ Branch 3 not taken.
3132409 if(!p_igetl(&(temp_script.arg2),f))
12828 return qe_invalid;
12829
12830
2/4
✓ Branch 0 taken 3132409 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3132409 times.
✗ Branch 3 not taken.
3132409 if(!p_igetl(&(temp_script.arg3),f))
12831 return qe_invalid;
12832
12833 3132409 uint32_t sz = 0;
12834
2/4
✓ Branch 0 taken 3132409 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3132409 times.
✗ Branch 3 not taken.
3132409 if(!p_igetl(&sz,f))
12835 return qe_invalid;
12836
2/2
✓ Branch 0 taken 37000 times.
✓ Branch 1 taken 3095409 times.
3132409 if(sz) //string found
12837 {
12838
1/2
✓ Branch 0 taken 37000 times.
✗ Branch 1 not taken.
37000 temp_script.strptr = new std::string();
12839 char dummy;
12840
2/2
✓ Branch 0 taken 673835 times.
✓ Branch 1 taken 37000 times.
710835 for(size_t q = 0; q < sz; ++q)
12841 {
12842
2/4
✓ Branch 0 taken 673835 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 673835 times.
✗ Branch 3 not taken.
673835 if(!p_getc(&dummy,f))
12843 return qe_invalid;
12844
1/2
✓ Branch 0 taken 673835 times.
✗ Branch 1 not taken.
673835 temp_script.strptr->push_back(dummy);
12845 673835 }
12846 37000 }
12847
2/4
✓ Branch 0 taken 3132409 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3132409 times.
✗ Branch 3 not taken.
3132409 if(!p_igetl(&sz,f))
12848 return qe_invalid;
12849
2/2
✓ Branch 0 taken 5251 times.
✓ Branch 1 taken 3127158 times.
3132409 if(sz) //vector found
12850 {
12851
1/2
✓ Branch 0 taken 5251 times.
✗ Branch 1 not taken.
5251 temp_script.vecptr = new std::vector<int32_t>();
12852 int32_t dummy;
12853
2/2
✓ Branch 0 taken 16156 times.
✓ Branch 1 taken 5251 times.
21407 for(size_t q = 0; q < sz; ++q)
12854 {
12855
2/4
✓ Branch 0 taken 16156 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16156 times.
✗ Branch 3 not taken.
16156 if(!p_igetl(&dummy,f))
12856 return qe_invalid;
12857
1/2
✓ Branch 0 taken 16156 times.
✗ Branch 1 not taken.
16156 temp_script.vecptr->push_back(dummy);
12858 16156 }
12859 5251 }
12860
1/2
✓ Branch 0 taken 3132409 times.
✗ Branch 1 not taken.
3132409 zasm.emplace_back(std::move(temp_script));
12861
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3132409 times.
3132409 }
12862
12863
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 assert(zasm_scripts.empty());
12864 124 zasm_script_id id = zasm_scripts.size();
12865
2/4
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 124 times.
124 zasm_scripts.emplace_back(std::make_shared<zasm_script>(id, "@single", std::move(zasm)));
12866
12867 124 return 0;
12868 124 }
12869
12870 1044033 int32_t read_one_ffscript(PACKFILE *f, zquestheader *, int32_t script_index, word s_version, script_data *script, word zmeta_version)
12871 {
12872 ASSERT(script);
12873
2/2
✓ Branch 0 taken 566261 times.
✓ Branch 1 taken 477772 times.
1044033 if(s_version < 27)
12874 566261 return read_old_ffscript(f, script_index, s_version, script, zmeta_version);
12875
12876 char exists;
12877
1/2
✓ Branch 0 taken 477772 times.
✗ Branch 1 not taken.
477772 if (!p_getc(&exists, f))
12878 return qe_invalid;
12879
2/2
✓ Branch 0 taken 3545 times.
✓ Branch 1 taken 474227 times.
477772 if (!exists)
12880 {
12881 474227 script->disable();
12882 474227 return 0;
12883 }
12884
12885 //Read meta
12886 {
12887 3545 zasm_meta temp_meta;
12888
12889
2/4
✓ Branch 0 taken 3545 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3545 times.
✗ Branch 3 not taken.
3545 if(!p_igetw(&(temp_meta.zasm_v),f))
12890 return qe_invalid;
12891
2/4
✓ Branch 0 taken 3545 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3545 times.
✗ Branch 3 not taken.
3545 if(!p_igetw(&(temp_meta.meta_v),f))
12892 return qe_invalid;
12893
2/4
✓ Branch 0 taken 3545 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3545 times.
✗ Branch 3 not taken.
3545 if(!p_igetw(&(temp_meta.ffscript_v),f))
12894 return qe_invalid;
12895
2/4
✓ Branch 0 taken 3545 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3545 times.
✗ Branch 3 not taken.
3545 if(!p_getc(&(temp_meta.script_type),f))
12896 return qe_invalid;
12897
12898
2/2
✓ Branch 0 taken 28360 times.
✓ Branch 1 taken 3545 times.
31905 for(int32_t q = 0; q < 8; ++q)
12899 {
12900
2/4
✓ Branch 0 taken 28360 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 28360 times.
✗ Branch 3 not taken.
28360 if(!p_getcstr(&temp_meta.run_idens[q],f))
12901 return qe_invalid;
12902 28360 }
12903
12904
2/2
✓ Branch 0 taken 3545 times.
✓ Branch 1 taken 28360 times.
31905 for(int32_t q = 0; q < 8; ++q)
12905
2/4
✓ Branch 0 taken 28360 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 28360 times.
✗ Branch 3 not taken.
28360 if(!p_getc(&(temp_meta.run_types[q]),f))
12906 return qe_invalid;
12907
12908
2/4
✓ Branch 0 taken 3545 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3545 times.
✗ Branch 3 not taken.
3545 if(!p_getc(&(temp_meta.flags),f))
12909 return qe_invalid;
12910
12911
2/4
✓ Branch 0 taken 3545 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3545 times.
✗ Branch 3 not taken.
3545 if(!p_igetw(&(temp_meta.compiler_v1),f))
12912 return qe_invalid;
12913
2/4
✓ Branch 0 taken 3545 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3545 times.
✗ Branch 3 not taken.
3545 if(!p_igetw(&(temp_meta.compiler_v2),f))
12914 return qe_invalid;
12915
2/4
✓ Branch 0 taken 3545 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3545 times.
✗ Branch 3 not taken.
3545 if(!p_igetw(&(temp_meta.compiler_v3),f))
12916 return qe_invalid;
12917
2/4
✓ Branch 0 taken 3545 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3545 times.
✗ Branch 3 not taken.
3545 if(!p_igetw(&(temp_meta.compiler_v4),f))
12918 return qe_invalid;
12919
12920
2/4
✓ Branch 0 taken 3545 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3545 times.
✗ Branch 3 not taken.
3545 if(!p_getcstr(&temp_meta.script_name,f))
12921 return qe_invalid;
12922
2/4
✓ Branch 0 taken 3545 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3545 times.
✗ Branch 3 not taken.
3545 if(!p_getcstr(&temp_meta.author,f))
12923 return qe_invalid;
12924 3545 auto num_meta_attrib = 10;
12925
2/2
✓ Branch 0 taken 35450 times.
✓ Branch 1 taken 3545 times.
38995 for(auto q = 0; q < num_meta_attrib; ++q)
12926 {
12927
2/4
✓ Branch 0 taken 35450 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 35450 times.
✗ Branch 3 not taken.
35450 if(!p_getcstr(&temp_meta.attributes[q],f))
12928 return qe_invalid;
12929
2/4
✓ Branch 0 taken 35450 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 35450 times.
✗ Branch 3 not taken.
35450 if(!p_getwstr(&temp_meta.attributes_help[q],f))
12930 return qe_invalid;
12931 35450 }
12932
2/2
✓ Branch 0 taken 28360 times.
✓ Branch 1 taken 3545 times.
31905 for(auto q = 0; q < 8; ++q)
12933 {
12934
2/4
✓ Branch 0 taken 28360 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 28360 times.
✗ Branch 3 not taken.
28360 if(!p_getcstr(&temp_meta.attribytes[q],f))
12935 return qe_invalid;
12936
2/4
✓ Branch 0 taken 28360 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 28360 times.
✗ Branch 3 not taken.
28360 if(!p_getwstr(&temp_meta.attribytes_help[q],f))
12937 return qe_invalid;
12938 28360 }
12939
2/2
✓ Branch 0 taken 28360 times.
✓ Branch 1 taken 3545 times.
31905 for(auto q = 0; q < 8; ++q)
12940 {
12941
2/4
✓ Branch 0 taken 28360 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 28360 times.
✗ Branch 3 not taken.
28360 if(!p_getcstr(&temp_meta.attrishorts[q],f))
12942 return qe_invalid;
12943
2/4
✓ Branch 0 taken 28360 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 28360 times.
✗ Branch 3 not taken.
28360 if(!p_getwstr(&temp_meta.attrishorts_help[q],f))
12944 return qe_invalid;
12945 28360 }
12946
2/2
✓ Branch 0 taken 56720 times.
✓ Branch 1 taken 3545 times.
60265 for(auto q = 0; q < 16; ++q)
12947 {
12948
2/4
✓ Branch 0 taken 56720 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 56720 times.
✗ Branch 3 not taken.
56720 if(!p_getcstr(&temp_meta.usrflags[q],f))
12949 return qe_invalid;
12950
2/4
✓ Branch 0 taken 56720 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 56720 times.
✗ Branch 3 not taken.
56720 if(!p_getwstr(&temp_meta.usrflags_help[q],f))
12951 return qe_invalid;
12952 56720 }
12953
2/2
✓ Branch 0 taken 28360 times.
✓ Branch 1 taken 3545 times.
31905 for(auto q = 0; q < 8; ++q)
12954 {
12955
2/4
✓ Branch 0 taken 28360 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 28360 times.
✗ Branch 3 not taken.
28360 if(!p_getcstr(&temp_meta.initd[q],f))
12956 return qe_invalid;
12957
2/4
✓ Branch 0 taken 28360 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 28360 times.
✗ Branch 3 not taken.
28360 if(!p_getwstr(&temp_meta.initd_help[q],f))
12958 return qe_invalid;
12959 28360 }
12960
2/2
✓ Branch 0 taken 3545 times.
✓ Branch 1 taken 28360 times.
31905 for(auto q = 0; q < 8; ++q)
12961 {
12962
2/4
✓ Branch 0 taken 28360 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 28360 times.
✗ Branch 3 not taken.
28360 if(!p_getc(&temp_meta.initd_type[q],f))
12963 return qe_invalid;
12964 28360 }
12965
12966
1/2
✓ Branch 0 taken 3545 times.
✗ Branch 1 not taken.
3545 script->meta = temp_meta;
12967
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 3545 times.
3545 }
12968
1/2
✓ Branch 0 taken 3545 times.
✗ Branch 1 not taken.
3545 if(!p_igetl(&script->pc, f))
12969 return qe_invalid;
12970
1/2
✓ Branch 0 taken 3545 times.
✗ Branch 1 not taken.
3545 if(!p_igetl(&script->end_pc, f))
12971 return qe_invalid;
12972
12973
1/2
✓ Branch 0 taken 3545 times.
✗ Branch 1 not taken.
3545 if (script == &fake_script_data)
12974 return 0;
12975
12976
1/2
✓ Branch 0 taken 3545 times.
✗ Branch 1 not taken.
3545 assert(zasm_scripts.size() == 1);
12977 3545 auto& zs = zasm_scripts[0];
12978 3545 script->zasm_script = zs;
12979
12980
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3545 times.
3545 if (script->valid())
12981 {
12982 3545 zs->script_datas.push_back(script);
12983 3545 read_scripts.push_back(script);
12984 3545 }
12985
12986 3545 return 0;
12987 1044033 }
12988
12989 566261 int32_t read_old_ffscript(PACKFILE *f, int32_t script_index, word s_version, script_data *script, word zmeta_version)
12990 {
12991 566261 char b33[34] = {0};
12992 566261 b33[33] = 0;
12993 566261 int32_t num_commands=1000;
12994
12995
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 566261 times.
566261 if(s_version>=2)
12996 {
12997
1/2
✓ Branch 0 taken 566261 times.
✗ Branch 1 not taken.
566261 if(!p_igetl(&num_commands,f))
12998 {
12999 return qe_invalid;
13000 }
13001 566261 }
13002
13003 #ifdef ZC_FUZZ
13004 const int32_t command_limit = 300000;
13005 #else
13006 566261 const int32_t command_limit = 10000000;
13007 #endif
13008
2/4
✓ Branch 0 taken 566261 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 566261 times.
566261 if (num_commands < 0 || num_commands > command_limit)
13009 {
13010 return qe_invalid;
13011 }
13012
13013 566261 std::vector<ffscript> zasm;
13014
1/2
✓ Branch 0 taken 566261 times.
✗ Branch 1 not taken.
566261 zasm.reserve(num_commands);
13015
13016
2/2
✓ Branch 0 taken 249946 times.
✓ Branch 1 taken 316315 times.
566261 if(s_version >= 16)
13017 {
13018
1/2
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
249946 zasm_meta temp_meta;
13019
13020
2/4
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249946 times.
✗ Branch 3 not taken.
249946 if(!p_igetw(&(temp_meta.zasm_v),f))
13021 {
13022 return qe_invalid;
13023 }
13024
13025
2/4
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249946 times.
✗ Branch 3 not taken.
249946 if(!p_igetw(&(temp_meta.meta_v),f))
13026 {
13027 return qe_invalid;
13028 }
13029
13030
2/4
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249946 times.
✗ Branch 3 not taken.
249946 if(!p_igetw(&(temp_meta.ffscript_v),f))
13031 {
13032 return qe_invalid;
13033 }
13034
13035
2/4
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249946 times.
✗ Branch 3 not taken.
249946 if(!p_getc(&(temp_meta.script_type),f))
13036 {
13037 return qe_invalid;
13038 }
13039
13040
2/2
✓ Branch 0 taken 1999568 times.
✓ Branch 1 taken 249946 times.
2249514 for(int32_t q = 0; q < 8; ++q)
13041 {
13042
2/2
✓ Branch 0 taken 143880 times.
✓ Branch 1 taken 1855688 times.
1999568 if(zmeta_version < 3)
13043 {
13044
2/2
✓ Branch 0 taken 143880 times.
✓ Branch 1 taken 4748040 times.
4891920 for(int32_t c = 0; c < 33; ++c)
13045 {
13046
2/4
✓ Branch 0 taken 4748040 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4748040 times.
✗ Branch 3 not taken.
4748040 if(!p_getc(&(b33[c]),f))
13047 {
13048 return qe_invalid;
13049 }
13050 4748040 }
13051
1/2
✓ Branch 0 taken 143880 times.
✗ Branch 1 not taken.
143880 temp_meta.run_idens[q].assign(b33);
13052 143880 }
13053 else
13054 {
13055
2/4
✓ Branch 0 taken 1855688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1855688 times.
✗ Branch 3 not taken.
1855688 if(!p_getcstr(&temp_meta.run_idens[q],f))
13056 {
13057 return qe_invalid;
13058 }
13059 }
13060 1999568 }
13061
13062
2/2
✓ Branch 0 taken 249946 times.
✓ Branch 1 taken 1999568 times.
2249514 for(int32_t q = 0; q < 8; ++q)
13063 {
13064
2/4
✓ Branch 0 taken 1999568 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1999568 times.
✗ Branch 3 not taken.
1999568 if(!p_getc(&(temp_meta.run_types[q]),f))
13065 {
13066 return qe_invalid;
13067 }
13068 1999568 }
13069
13070
2/4
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249946 times.
✗ Branch 3 not taken.
249946 if(!p_getc(&(temp_meta.flags),f))
13071 {
13072 return qe_invalid;
13073 }
13074
13075
2/4
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249946 times.
✗ Branch 3 not taken.
249946 if(!p_igetw(&(temp_meta.compiler_v1),f))
13076 {
13077 return qe_invalid;
13078 }
13079
13080
2/4
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249946 times.
✗ Branch 3 not taken.
249946 if(!p_igetw(&(temp_meta.compiler_v2),f))
13081 {
13082 return qe_invalid;
13083 }
13084
13085
2/4
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249946 times.
✗ Branch 3 not taken.
249946 if(!p_igetw(&(temp_meta.compiler_v3),f))
13086 {
13087 return qe_invalid;
13088 }
13089
13090
2/4
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249946 times.
✗ Branch 3 not taken.
249946 if(!p_igetw(&(temp_meta.compiler_v4),f))
13091 {
13092 return qe_invalid;
13093 }
13094
13095
2/2
✓ Branch 0 taken 17985 times.
✓ Branch 1 taken 231961 times.
249946 if(zmeta_version == 2)
13096 {
13097
2/2
✓ Branch 0 taken 17985 times.
✓ Branch 1 taken 593505 times.
611490 for(int32_t c = 0; c < 33; ++c)
13098 {
13099
2/4
✓ Branch 0 taken 593505 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 593505 times.
✗ Branch 3 not taken.
593505 if(!p_getc(&b33[c],f))
13100 {
13101 return qe_invalid;
13102 }
13103 593505 }
13104
1/2
✓ Branch 0 taken 17985 times.
✗ Branch 1 not taken.
17985 temp_meta.script_name.assign(b33);
13105
13106
2/2
✓ Branch 0 taken 17985 times.
✓ Branch 1 taken 593505 times.
611490 for(int32_t c = 0; c < 33; ++c)
13107 {
13108
2/4
✓ Branch 0 taken 593505 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 593505 times.
✗ Branch 3 not taken.
593505 if(!p_getc(&b33[c],f))
13109 {
13110 return qe_invalid;
13111 }
13112 593505 }
13113
1/2
✓ Branch 0 taken 17985 times.
✗ Branch 1 not taken.
17985 temp_meta.author.assign(b33);
13114 17985 }
13115
1/2
✓ Branch 0 taken 231961 times.
✗ Branch 1 not taken.
231961 else if(zmeta_version > 2)
13116 {
13117
2/4
✓ Branch 0 taken 231961 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 231961 times.
✗ Branch 3 not taken.
231961 if(!p_getcstr(&temp_meta.script_name,f))
13118 return qe_invalid;
13119
2/4
✓ Branch 0 taken 231961 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 231961 times.
✗ Branch 3 not taken.
231961 if(!p_getcstr(&temp_meta.author,f))
13120 return qe_invalid;
13121 231961 auto num_meta_attrib = (zmeta_version < 5 ? 4 : 10);
13122
2/2
✓ Branch 0 taken 2319610 times.
✓ Branch 1 taken 231961 times.
2551571 for(auto q = 0; q < num_meta_attrib; ++q)
13123 {
13124
2/4
✓ Branch 0 taken 2319610 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2319610 times.
✗ Branch 3 not taken.
2319610 if(!p_getcstr(&temp_meta.attributes[q],f))
13125 return qe_invalid;
13126
2/4
✓ Branch 0 taken 2319610 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2319610 times.
✗ Branch 3 not taken.
2319610 if(!p_getwstr(&temp_meta.attributes_help[q],f))
13127 return qe_invalid;
13128 2319610 }
13129
2/2
✓ Branch 0 taken 1855688 times.
✓ Branch 1 taken 231961 times.
2087649 for(auto q = 0; q < 8; ++q)
13130 {
13131
2/4
✓ Branch 0 taken 1855688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1855688 times.
✗ Branch 3 not taken.
1855688 if(!p_getcstr(&temp_meta.attribytes[q],f))
13132 return qe_invalid;
13133
2/4
✓ Branch 0 taken 1855688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1855688 times.
✗ Branch 3 not taken.
1855688 if(!p_getwstr(&temp_meta.attribytes_help[q],f))
13134 return qe_invalid;
13135 1855688 }
13136
2/2
✓ Branch 0 taken 1855688 times.
✓ Branch 1 taken 231961 times.
2087649 for(auto q = 0; q < 8; ++q)
13137 {
13138
2/4
✓ Branch 0 taken 1855688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1855688 times.
✗ Branch 3 not taken.
1855688 if(!p_getcstr(&temp_meta.attrishorts[q],f))
13139 return qe_invalid;
13140
2/4
✓ Branch 0 taken 1855688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1855688 times.
✗ Branch 3 not taken.
1855688 if(!p_getwstr(&temp_meta.attrishorts_help[q],f))
13141 return qe_invalid;
13142 1855688 }
13143
2/2
✓ Branch 0 taken 3711376 times.
✓ Branch 1 taken 231961 times.
3943337 for(auto q = 0; q < 16; ++q)
13144 {
13145
2/4
✓ Branch 0 taken 3711376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3711376 times.
✗ Branch 3 not taken.
3711376 if(!p_getcstr(&temp_meta.usrflags[q],f))
13146 return qe_invalid;
13147
2/4
✓ Branch 0 taken 3711376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3711376 times.
✗ Branch 3 not taken.
3711376 if(!p_getwstr(&temp_meta.usrflags_help[q],f))
13148 return qe_invalid;
13149 3711376 }
13150 231961 }
13151
2/2
✓ Branch 0 taken 231961 times.
✓ Branch 1 taken 17985 times.
249946 if(zmeta_version > 3)
13152 {
13153
2/2
✓ Branch 0 taken 1855688 times.
✓ Branch 1 taken 231961 times.
2087649 for(auto q = 0; q < 8; ++q)
13154 {
13155
2/4
✓ Branch 0 taken 1855688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1855688 times.
✗ Branch 3 not taken.
1855688 if(!p_getcstr(&temp_meta.initd[q],f))
13156 return qe_invalid;
13157
2/4
✓ Branch 0 taken 1855688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1855688 times.
✗ Branch 3 not taken.
1855688 if(!p_getwstr(&temp_meta.initd_help[q],f))
13158 return qe_invalid;
13159 1855688 }
13160
2/2
✓ Branch 0 taken 1855688 times.
✓ Branch 1 taken 231961 times.
2087649 for(auto q = 0; q < 8; ++q)
13161 {
13162
2/4
✓ Branch 0 taken 1855688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1855688 times.
✗ Branch 3 not taken.
1855688 if(!p_getc(&temp_meta.initd_type[q],f))
13163 return qe_invalid;
13164 1855688 }
13165 231961 }
13166 else
13167 {
13168
2/2
✓ Branch 0 taken 143880 times.
✓ Branch 1 taken 17985 times.
161865 for(auto q = 0; q < 8; ++q)
13169 {
13170
1/2
✓ Branch 0 taken 143880 times.
✗ Branch 1 not taken.
143880 temp_meta.initd[q] = temp_meta.run_idens[q];
13171 143880 }
13172 }
13173
13174
1/2
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
249946 script->meta = temp_meta;
13175
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 249946 times.
✓ Branch 2 taken 316315 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 316315 times.
✗ Branch 5 not taken.
566261 } else script->meta = {};
13176
13177
2/2
✓ Branch 0 taken 74674 times.
✓ Branch 1 taken 107364918 times.
107439592 for(int32_t j=0; j<num_commands; j++)
13178 {
13179
1/2
✓ Branch 0 taken 107364918 times.
✗ Branch 1 not taken.
107364918 auto& sc = zasm.emplace_back();
13180
2/4
✓ Branch 0 taken 107364918 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 107364918 times.
✗ Branch 3 not taken.
107364918 if(!p_igetw(&sc.command,f))
13181 {
13182 return qe_invalid;
13183 }
13184
13185
2/2
✓ Branch 0 taken 106873331 times.
✓ Branch 1 taken 491587 times.
107364918 if(sc.command == 0xFFFF)
13186 491587 break;
13187 else
13188 {
13189
2/4
✓ Branch 0 taken 106873331 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 106873331 times.
✗ Branch 3 not taken.
106873331 if(!p_igetl(&sc.arg1,f))
13190 {
13191 return qe_invalid;
13192 }
13193
13194
2/4
✓ Branch 0 taken 106873331 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 106873331 times.
✗ Branch 3 not taken.
106873331 if(!p_igetl(&sc.arg2,f))
13195 {
13196 return qe_invalid;
13197 }
13198
13199
2/2
✓ Branch 0 taken 1047747 times.
✓ Branch 1 taken 105825584 times.
106873331 if(s_version >= 24)
13200
2/4
✓ Branch 0 taken 1047747 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1047747 times.
✗ Branch 3 not taken.
1047747 if(!p_igetl(&sc.arg3,f))
13201 return qe_invalid;
13202
13203
2/2
✓ Branch 0 taken 8222037 times.
✓ Branch 1 taken 98651294 times.
106873331 if(s_version >= 21)
13204 {
13205 8222037 uint32_t sz = 0;
13206
2/4
✓ Branch 0 taken 8222037 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8222037 times.
✗ Branch 3 not taken.
8222037 if(!p_igetl(&sz,f))
13207 {
13208 return qe_invalid;
13209 }
13210
2/2
✓ Branch 0 taken 19400 times.
✓ Branch 1 taken 8202637 times.
8222037 if(sz) //string found
13211 {
13212
1/2
✓ Branch 0 taken 19400 times.
✗ Branch 1 not taken.
19400 sc.strptr = new std::string();
13213 char dummy;
13214
2/2
✓ Branch 0 taken 1165008 times.
✓ Branch 1 taken 19400 times.
1184408 for(size_t q = 0; q < sz; ++q)
13215 {
13216
2/4
✓ Branch 0 taken 1165008 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1165008 times.
✗ Branch 3 not taken.
1165008 if(!p_getc(&dummy,f))
13217 {
13218 return qe_invalid;
13219 }
13220
1/2
✓ Branch 0 taken 1165008 times.
✗ Branch 1 not taken.
1165008 sc.strptr->push_back(dummy);
13221 1165008 }
13222 19400 }
13223
2/4
✓ Branch 0 taken 8222037 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8222037 times.
✗ Branch 3 not taken.
8222037 if(!p_igetl(&sz,f))
13224 {
13225 return qe_invalid;
13226 }
13227
2/2
✓ Branch 0 taken 933 times.
✓ Branch 1 taken 8221104 times.
8222037 if(sz) //vector found
13228 {
13229
1/2
✓ Branch 0 taken 933 times.
✗ Branch 1 not taken.
933 sc.vecptr = new std::vector<int32_t>();
13230 int32_t dummy;
13231
2/2
✓ Branch 0 taken 11526 times.
✓ Branch 1 taken 933 times.
12459 for(size_t q = 0; q < sz; ++q)
13232 {
13233
2/4
✓ Branch 0 taken 11526 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11526 times.
✗ Branch 3 not taken.
11526 if(!p_igetl(&dummy,f))
13234 {
13235 return qe_invalid;
13236 }
13237
1/2
✓ Branch 0 taken 11526 times.
✗ Branch 1 not taken.
11526 sc.vecptr->push_back(dummy);
13238 11526 }
13239 933 }
13240 8222037 }
13241 }
13242 106873331 }
13243
13244
2/2
✓ Branch 0 taken 496885 times.
✓ Branch 1 taken 69376 times.
566261 if (script == &fake_script_data)
13245 69376 return 0;
13246
13247 // If the first command is unknown, invalidate the whole thing.
13248 // Saw this for https://www.purezc.net/index.php?page=quests&id=411 hero script 0
13249
5/6
✓ Branch 0 taken 427587 times.
✓ Branch 1 taken 69298 times.
✓ Branch 2 taken 415407 times.
✓ Branch 3 taken 12180 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 415407 times.
496885 if (!zasm.empty() && zasm[0].command >= NUMCOMMANDS && zasm[0].command != 0xFFFF)
13250 {
13251 al_trace("Warning: found script with bad instruction, disabling script: %s %d\n", ScriptTypeToString(script->id.type), script->id.index);
13252 zasm.clear();
13253 }
13254
13255 496885 zasm_script_id id = zasm_scripts.size();
13256
3/6
✓ Branch 0 taken 496885 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 496885 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 496885 times.
✗ Branch 5 not taken.
496885 auto& zs = zasm_scripts.emplace_back(std::make_shared<zasm_script>(id, script->name(), std::move(zasm)));
13257 496885 script->zasm_script = zs;
13258 496885 script->pc = 0;
13259 496885 script->end_pc = zs->size;
13260
3/4
✓ Branch 0 taken 496885 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12180 times.
✓ Branch 3 taken 484705 times.
496885 if (script->valid())
13261 {
13262
1/2
✓ Branch 0 taken 12180 times.
✗ Branch 1 not taken.
12180 zs->script_datas.push_back(script);
13263
1/2
✓ Branch 0 taken 12180 times.
✗ Branch 1 not taken.
12180 read_scripts.push_back(script);
13264 12180 }
13265
13266 496885 return 0;
13267 566261 }
13268
13269 extern SAMPLE customsfxdata[WAV_COUNT];
13270 extern uint8_t customsfxflag[WAV_COUNT>>3];
13271 extern int32_t sfxdat;
13272 extern DATAFILE *sfxdata;
13273 const char *old_sfx_string[Z35] =
13274 {
13275 "Arrow", "Sword beam", "Bomb blast", "Boomerang", "Subscreen cursor",
13276 "Shield is hit", "Item chime", "Roar (Dodongo, Gohma)", "Shutter", "Enemy dies",
13277 "Enemy is hit", "Low hearts warning", "Fire", "Ganon's fanfare", "Boss is hit", "Hammer",
13278 "Hookshot", "Message", "Hero is hit", "Item fanfare", "Bomb placed", "Item pickup",
13279 "Refill", "Roar (Aquamentus, Gleeok, Ganon)", "Item pickup 2", "Ocean ambience",
13280 "Secret chime", "Hero dies", "Stairs", "Sword", "Roar (Manhandla, Digdogger, Patra)",
13281 "Wand magic", "Whistle", "Zelda's fanfare", "Charging weapon", "Charging weapon 2",
13282 "Divine Fire", "Enemy falls from ceiling", "Divine Escape", "Fireball", "Tall Grass slashed",
13283 "Pound pounded", "Hover Boots", "Ice magic", "Jump", "Lens of Truth off", "Lens of Truth on",
13284 "Divine Protection shield", "Divine Protection 2", "Push block", "Rock", "Spell rocket down",
13285 "Spell rocket up", "Sword spin attack", "Splash", "Summon magic", "Sword tapping",
13286 "Sword tapping (secret)", "Whistle whirlwind", "Cane of Byrna orbit"
13287 };
13288 char *sfx_string[WAV_COUNT];
13289
13290 395 int32_t readsfx(PACKFILE *f, zquestheader *Header)
13291 {
13292 //these are here to bypass compiler warnings about unused arguments
13293 395 Header=Header;
13294
13295 int32_t dummy;
13296 395 word s_version=0;
13297 //int32_t ret;
13298 395 SAMPLE temp_sample = {};
13299 395 temp_sample.loop_start=0;
13300 395 temp_sample.loop_end=0;
13301 395 temp_sample.param=0;
13302
13303 //section version info
13304
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 395 times.
395 if(!p_igetw(&s_version,f))
13305 {
13306 return qe_invalid;
13307 }
13308
13309 395 FFCore.quest_format[vSFX] = s_version;
13310
13311
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 if(!read_deprecated_section_cversion(f))
13312 {
13313 return qe_invalid;
13314 }
13315
13316 //section size
13317
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 if(!p_igetl(&dummy,f))
13318 {
13319 return qe_invalid;
13320 }
13321
13322 /* HIGHLY UNORTHODOX UPDATING THING, by L
13323 * This fixes quests made before revision 411 (such as the 'Lost Isle Build'),
13324 * where the meaning of GOTOLESS changed. It also coincided with V_SFX
13325 * changing from 1 to 2.
13326 */
13327
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 if(s_version < 2)
13328 set_qr(qr_GOTOLESSNOTEQUAL,1);
13329
13330 /* End highly unorthodox updating thing */
13331
13332 395 int32_t wavcount = WAV_COUNT;
13333
13334
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 if(s_version < 6)
13335 wavcount = 128;
13336
13337 uint8_t tempflag[WAV_COUNT>>3];
13338
13339
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 395 times.
395 if(s_version < 4)
13340 {
13341 memset(tempflag, 0xFF, WAV_COUNT>>3);
13342 }
13343 else
13344 {
13345
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 if(s_version < 6)
13346 memset(tempflag, 0, WAV_COUNT>>3);
13347
13348
2/2
✓ Branch 0 taken 12640 times.
✓ Branch 1 taken 395 times.
13035 for(int32_t i=0; i<(wavcount>>3); i++)
13349 {
13350 12640 p_getc(&tempflag[i], f);
13351 12640 }
13352
13353 }
13354
13355
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 if(s_version>4)
13356 {
13357
2/2
✓ Branch 0 taken 100725 times.
✓ Branch 1 taken 395 times.
101120 for(int32_t i=1; i<WAV_COUNT; i++)
13358 {
13359 100725 sprintf(sfx_string[i],"s%03d",i);
13360
13361
2/2
✓ Branch 0 taken 77025 times.
✓ Branch 1 taken 23700 times.
100725 if((i<Z35))
13362 23700 strcpy(sfx_string[i], old_sfx_string[i-1]);
13363
13364
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100725 times.
100725 if(i>=wavcount)
13365 continue;
13366
2/2
✓ Branch 0 taken 20432 times.
✓ Branch 1 taken 80293 times.
100725 if(get_bit(tempflag, i-1))
13367 {
13368 char tempname[36];
13369
13370
1/2
✓ Branch 0 taken 20432 times.
✗ Branch 1 not taken.
20432 if(!pfread(tempname, 36, f))
13371 {
13372 return qe_invalid;
13373 }
13374
13375 20432 sfx_string[i][0] = '\0';
13376 20432 strncat(sfx_string[i], tempname, 36 - 1);
13377 20432 }
13378 else
13379 {
13380 80293 sprintf(sfx_string[i],"s%03d",i);
13381
13382
2/2
✓ Branch 0 taken 70391 times.
✓ Branch 1 taken 9902 times.
80293 if(i<Z35)
13383 9902 strcpy(sfx_string[i], old_sfx_string[i-1]);
13384 80293 sfx_string[i][35] = 0; //Force NULL Termination
13385 }
13386 100725 }
13387 395 }
13388 else
13389 {
13390 for(int32_t i=1; i<WAV_COUNT; i++)
13391 {
13392 sprintf(sfx_string[i],"s%03d",i);
13393
13394 if(i<Z35)
13395 strcpy(sfx_string[i], old_sfx_string[i-1]);
13396 }
13397 }
13398
13399 //finally... section data
13400
2/2
✓ Branch 0 taken 100725 times.
✓ Branch 1 taken 395 times.
101120 for(int32_t i=1; i<wavcount; i++)
13401 {
13402
2/2
✓ Branch 0 taken 20432 times.
✓ Branch 1 taken 80293 times.
100725 if(get_bit(tempflag, i-1))
13403 {
13404
13405
1/2
✓ Branch 0 taken 20432 times.
✗ Branch 1 not taken.
20432 if(!p_igetl(&dummy,f))
13406 {
13407 return qe_invalid;
13408 }
13409
13410 20432 (temp_sample.bits) = dummy;
13411
13412
1/2
✓ Branch 0 taken 20432 times.
✗ Branch 1 not taken.
20432 if(!p_igetl(&dummy,f))
13413 {
13414 return qe_invalid;
13415 }
13416
13417 20432 (temp_sample.stereo) = dummy;
13418
13419
1/2
✓ Branch 0 taken 20432 times.
✗ Branch 1 not taken.
20432 if(!p_igetl(&dummy,f))
13420 {
13421 return qe_invalid;
13422 }
13423
13424 20432 (temp_sample.freq) = dummy;
13425
13426
1/2
✓ Branch 0 taken 20432 times.
✗ Branch 1 not taken.
20432 if(!p_igetl(&dummy,f))
13427 {
13428 return qe_invalid;
13429 }
13430
13431 20432 (temp_sample.priority) = dummy;
13432
13433
1/2
✓ Branch 0 taken 20432 times.
✗ Branch 1 not taken.
20432 if(!p_igetl(&(temp_sample.len),f))
13434 {
13435 return qe_invalid;
13436 }
13437
13438
1/2
✓ Branch 0 taken 20432 times.
✗ Branch 1 not taken.
20432 if(!p_igetl(&(temp_sample.loop_start),f))
13439 {
13440 return qe_invalid;
13441 }
13442
13443
1/2
✓ Branch 0 taken 20432 times.
✗ Branch 1 not taken.
20432 if(!p_igetl(&(temp_sample.loop_end),f))
13444 {
13445 return qe_invalid;
13446 }
13447
13448
1/2
✓ Branch 0 taken 20432 times.
✗ Branch 1 not taken.
20432 if(!p_igetl(&(temp_sample.param),f))
13449 {
13450 return qe_invalid;
13451 }
13452
13453 20432 auto len = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13454 #ifdef ZC_FUZZ
13455 const int32_t sfx_limit = 100000;
13456 if (len < 0 || len > sfx_limit)
13457 {
13458 return qe_invalid;
13459 }
13460 #endif
13461 20432 temp_sample.data = calloc(len,1);
13462
13463
1/2
✓ Branch 0 taken 20432 times.
✗ Branch 1 not taken.
20432 if(s_version < 3)
13464 len = (temp_sample.bits==8?1:2)*temp_sample.len;
13465
13466 //old-style, non-portable loading (Bad Allegro! Bad!!) -DD
13467
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20432 times.
20432 if(s_version < 2)
13468 {
13469 if(!pfread(temp_sample.data, len,f))
13470 {
13471 return qe_invalid;
13472 }
13473 }
13474 else
13475 {
13476 //re-endianfy the data
13477 20432 int32_t wordstoread = len / sizeof(word);
13478
13479
2/2
✓ Branch 0 taken 565877116 times.
✓ Branch 1 taken 20432 times.
565897548 for(int32_t j=0; j<wordstoread; j++)
13480 {
13481 word temp;
13482
13483
1/2
✓ Branch 0 taken 565877116 times.
✗ Branch 1 not taken.
565877116 if(!p_igetw(&temp, f))
13484 {
13485 return qe_invalid;
13486 }
13487
13488 565877116 ((word *)temp_sample.data)[j] = temp;
13489 565877116 }
13490 }
13491 20432 }
13492
2/2
✓ Branch 0 taken 9902 times.
✓ Branch 1 taken 70391 times.
80293 else if(i < Z35)
13493 {
13494 9902 SAMPLE* datsamp = (SAMPLE*)(sfxdata[i].dat);
13495 9902 memcpy(&temp_sample, datsamp, sizeof(SAMPLE));
13496 9902 set_bit(tempflag, i-1, 1);
13497 9902 int32_t len = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13498 9902 temp_sample.data = calloc(len,1);
13499 9902 memcpy(temp_sample.data, datsamp->data, len);
13500 9902 }
13501 70391 else continue;
13502
13503
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30334 times.
30334 if(customsfxdata[i].data!=NULL)
13504 {
13505 // delete [] customsfxdata[i].data;
13506 30334 free(customsfxdata[i].data);
13507 30334 }
13508
13509 // customsfxdata[i].data = new byte[(temp_sample.bits==8?1:2)*temp_sample.len];
13510 30334 int32_t len2 = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13511 30334 customsfxdata[i].data = calloc(len2,1);
13512 30334 customsfxdata[i].bits = temp_sample.bits;
13513 30334 customsfxdata[i].stereo = temp_sample.stereo;
13514 30334 customsfxdata[i].freq = temp_sample.freq;
13515 30334 customsfxdata[i].priority = temp_sample.priority;
13516 30334 customsfxdata[i].len = temp_sample.len;
13517 30334 customsfxdata[i].loop_start = temp_sample.loop_start;
13518 30334 customsfxdata[i].loop_end = temp_sample.loop_end;
13519 30334 customsfxdata[i].param = temp_sample.param;
13520 30334 int32_t cpylen = len2;
13521
13522
1/2
✓ Branch 0 taken 30334 times.
✗ Branch 1 not taken.
30334 if(s_version<3)
13523 {
13524 cpylen = (temp_sample.bits==8?1:2)*temp_sample.len;
13525 al_trace("WARNING: Quest SFX %d is in stereo, and may be corrupt.\n",i);
13526 }
13527
13528 30334 memcpy(customsfxdata[i].data,temp_sample.data,cpylen);
13529
13530 30334 free(temp_sample.data);
13531 30334 }
13532
13533 395 memcpy(customsfxflag, tempflag, WAV_COUNT>>3);
13534
13535 395 sfxdat=0;
13536 395 return 0;
13537 395 }
13538
13539 477 void setupsfx()
13540 {
13541
2/2
✓ Branch 0 taken 121635 times.
✓ Branch 1 taken 477 times.
122112 for(int32_t i=1; i<WAV_COUNT; i++)
13542 {
13543 121635 sprintf(sfx_string[i],"s%03d",i);
13544
13545
2/2
✓ Branch 0 taken 93015 times.
✓ Branch 1 taken 28620 times.
121635 if(i<Z35)
13546 {
13547 28620 strcpy(sfx_string[i], old_sfx_string[i-1]);
13548 28620 }
13549
13550 121635 memset(customsfxflag, 0, WAV_COUNT>>3);
13551
13552 121635 int32_t j=i;
13553
13554
2/2
✓ Branch 0 taken 29097 times.
✓ Branch 1 taken 92538 times.
121635 if(i>Z35)
13555 {
13556 92538 i=Z35;
13557 92538 }
13558
13559 121635 SAMPLE *temp_sample = (SAMPLE *)sfxdata[i].dat;
13560
13561
2/2
✓ Branch 0 taken 93840 times.
✓ Branch 1 taken 27795 times.
121635 if(customsfxdata[j].data!=NULL)
13562 {
13563 // delete [] customsfxdata[j].data;
13564 27795 free(customsfxdata[j].data);
13565 27795 }
13566
13567 // customsfxdata[j].data = new byte[(temp_sample->bits==8?1:2)*temp_sample->len];
13568 121635 customsfxdata[j].data = calloc((temp_sample->bits==8?1:2)*(temp_sample->stereo == 0 ? 1 : 2)*temp_sample->len,1);
13569 121635 customsfxdata[j].bits = temp_sample->bits;
13570 121635 customsfxdata[j].stereo = temp_sample->stereo;
13571 121635 customsfxdata[j].freq = temp_sample->freq;
13572 121635 customsfxdata[j].priority = temp_sample->priority;
13573 121635 customsfxdata[j].len = temp_sample->len;
13574 121635 customsfxdata[j].loop_start = temp_sample->loop_start;
13575 121635 customsfxdata[j].loop_end = temp_sample->loop_end;
13576 121635 customsfxdata[j].param = temp_sample->param;
13577 121635 memcpy(customsfxdata[j].data, (temp_sample->data), (temp_sample->bits==8?1:2)*(temp_sample->stereo==0 ? 1 : 2)*temp_sample->len);
13578 121635 i=j;
13579 121635 }
13580 477 }
13581
13582 extern char *guy_string[eMAXGUYS];
13583 extern const char *old_guy_string[OLDMAXGUYS];
13584
13585 477 int32_t readguys(PACKFILE *f, zquestheader *Header)
13586 {
13587
2/2
✓ Branch 0 taken 454 times.
✓ Branch 1 taken 23 times.
477 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_guys);
13588
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 477 times.
477 if (should_skip) return 0;
13589
13590 dword dummy;
13591 word guy_cversion;
13592 477 word guyversion=0;
13593
13594
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 454 times.
477 if(Header->zelda_version >= 0x193)
13595 {
13596 //section version info
13597
1/2
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
454 if(!p_igetw(&guyversion,f))
13598 {
13599 return qe_invalid;
13600 }
13601
13602 454 FFCore.quest_format[vGuys] = guyversion;
13603
13604 // Note: this is the only instance where "cversion" is ever used.
13605
1/2
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
454 if(!p_igetw(&guy_cversion,f))
13606 {
13607 return qe_invalid;
13608 }
13609
13610 //section size
13611
1/2
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
454 if(!p_igetl(&dummy,f))
13612 {
13613 return qe_invalid;
13614 }
13615 454 }
13616
13617
2/2
✓ Branch 0 taken 395 times.
✓ Branch 1 taken 82 times.
477 if(guyversion > 3)
13618 {
13619
2/2
✓ Branch 0 taken 202240 times.
✓ Branch 1 taken 395 times.
202635 for(int32_t i=0; i<MAXGUYS; i++)
13620 {
13621 char tempname[64];
13622
13623 // rev. 1511 : guyversion = 23. upped to 512 editable enemies. -Gleeok
13624 // if guyversion < 23 then there is only 256 enemies in the packfile, so default the rest.
13625
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 202240 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
202240 if(guyversion < 23 && i >= OLDBETAMAXGUYS)
13626 {
13627 memset(tempname, 0, sizeof(char)*64);
13628 sprintf(tempname, "e%03d", i);
13629 strcpy(guy_string[i], tempname);
13630
13631 continue;
13632 }
13633
13634
1/2
✓ Branch 0 taken 202240 times.
✗ Branch 1 not taken.
202240 if(!pfread(tempname, 64, f))
13635 {
13636 return qe_invalid;
13637 }
13638
13639 // Don't retain names of uneditable enemy entries!
13640 // for version upgrade to 2.5
13641
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 202240 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
202240 if(guyversion < 23 && i >= 177)
13642 {
13643 // some of the older builds have names such as 'zz123',
13644 // (this order gets messed up with some eXXX and some zzXXX)
13645 // so let's update to the newer naming convection. -Gleeok
13646 char tmpbuf[64];
13647 memset(tmpbuf, 0, sizeof(char)*64);
13648 sprintf(tmpbuf, "zz%03d", i);
13649
13650 if(memcmp(tempname, tmpbuf, size_t(5)) == 0)
13651 {
13652 memset(tempname, 0, sizeof(char)*64);
13653 sprintf(tempname, "e%03d", i);
13654 }
13655 }
13656
13657
6/6
✓ Branch 0 taken 69915 times.
✓ Branch 1 taken 132325 times.
✓ Branch 2 taken 66360 times.
✓ Branch 3 taken 3555 times.
✓ Branch 4 taken 57625 times.
✓ Branch 5 taken 8735 times.
202240 if(i >= OLDMAXGUYS || strlen(tempname)<1 || tempname[strlen(tempname)-1]!=' ')
13658 {
13659 193505 guy_string[i][0] = '\0';
13660 193505 strncat(guy_string[i], tempname, 64 - 1);
13661 193505 }
13662 else
13663 {
13664 8735 strcpy(guy_string[i],old_guy_string[i]);
13665 }
13666 202240 }
13667 395 }
13668 else
13669 {
13670
2/2
✓ Branch 0 taken 41984 times.
✓ Branch 1 taken 82 times.
42066 for(int32_t i=0; i<eMAXGUYS; i++)
13671 {
13672 41984 sprintf(guy_string[i],"zz%03d",i);
13673 41984 }
13674
13675
2/2
✓ Branch 0 taken 14514 times.
✓ Branch 1 taken 82 times.
14596 for(int32_t i=0; i<OLDMAXGUYS; i++)
13676 {
13677 14514 strcpy(guy_string[i],old_guy_string[i]);
13678 14514 }
13679 }
13680
13681
13682 //finally... section data
13683 477 init_guys(guyversion); //using default data for now...
13684
13685 // Goriya guy fix
13686
3/6
✓ Branch 0 taken 395 times.
✓ Branch 1 taken 82 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 395 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
477 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<7)))
13687 {
13688
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 60 times.
82 if(get_qr(qr_NEWENEMYTILES))
13689 {
13690 60 guysbuf[gGORIYA].tile=130;
13691 60 guysbuf[gGORIYA].e_tile=130;
13692 60 }
13693 82 }
13694
13695
2/2
✓ Branch 0 taken 454 times.
✓ Branch 1 taken 23 times.
477 if(Header->zelda_version < 0x193)
13696 {
13697
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 5 times.
23 if(get_bit(deprecated_rules,46))
13698 {
13699 5 guysbuf[eDODONGO].cset=14;
13700 5 guysbuf[eDODONGO].bosspal=spDIG;
13701 5 }
13702 23 }
13703 // Not sure when this first changed, but it's necessary for 2.10, at least
13704 // @TODO: @BUG:1.92 - 1.84? Figure this out exactly for the final 2.50 release.
13705 //2.10 Fixes
13706
3/6
✓ Branch 0 taken 395 times.
✓ Branch 1 taken 82 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 395 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
477 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<18)))
13707 {
13708 82 guysbuf[eWWIZ].editorflags |= ENEMY_FLAG5;
13709 82 guysbuf[eMOLDORM].editorflags |= ENEMY_FLAG6;
13710 82 guysbuf[eMANHAN].editorflags |= ENEMY_FLAG6;
13711 82 guysbuf[eCENT1].attributes[2] = 1;
13712 82 guysbuf[eCENT2].attributes[2] = 1;
13713 82 }
13714
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 477 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
477 if((Header->zelda_version <= 0x255) || (Header->zelda_version == 0x255 && Header->build < 47) )
13715 {
13716 477 guysbuf[eWPOLSV].defense[edefWhistle] = ed1HKO;
13717 477 }
13718
2/2
✓ Branch 0 taken 395 times.
✓ Branch 1 taken 82 times.
477 if(Header->zelda_version <= 0x210)
13719 {
13720 82 guysbuf[eGLEEOK1F].attributes[5] = 16;
13721 82 guysbuf[eGLEEOK2F].attributes[5] = 16;
13722 82 guysbuf[eGLEEOK3F].attributes[5] = 16;
13723 82 guysbuf[eGLEEOK4F].attributes[5] = 16;
13724
13725 82 guysbuf[eWIZ1].attributes[3] = 1; //only set the enemy that needs backward compat, not all of them.
13726 82 guysbuf[eBATROBE].attributes[3] = 1;
13727 //guysbuf[eSUMMONER].misc4 = 1;
13728 82 guysbuf[eWWIZ].attributes[3] = 1;
13729 82 guysbuf[eDODONGO].deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
13730 82 guysbuf[eDODONGOBS].deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
13731 82 }
13732
2/2
✓ Branch 0 taken 465 times.
✓ Branch 1 taken 12 times.
477 if(Header->zelda_version == 0x190)
13733 {
13734 12 al_trace("Setting Tribble Properties for Version: %x", Header->zelda_version);
13735 12 guysbuf[eKEESETRIB].attributes[2] = eVIRE; //1.90 and earlier, keese and gel tribbles grew up into
13736 12 guysbuf[eGELTRIB].attributes[2] = eZOL; //normal vires, and zols -Z (16th January, 2019 )
13737 12 }
13738
13739 // The versions here may not be correct
13740 // zelda_version>=0x211 handled at guyversion<24
13741
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 459 times.
477 if(Header->zelda_version <= 0x190)
13742 {
13743 18 guysbuf[eCENT1].attributes[2] = 0;
13744 18 guysbuf[eCENT2].attributes[2] = 0;
13745 18 guysbuf[eMOLDORM].attributes[1] = 0;
13746 //guysbuf[eKEESETRIB].misc3 = eVIRE; //1.90 and earlier, keese and gel tribbles grew up into
13747 //guysbuf[eGELTRIB].misc3 = eZOL; //normal vires, and zols -Z (16th January, 2019 )
13748 18 }
13749
2/2
✓ Branch 0 taken 395 times.
✓ Branch 1 taken 64 times.
459 else if(Header->zelda_version <= 0x210)
13750 {
13751 64 guysbuf[eCENT1].attributes[2] = 1;
13752 64 guysbuf[eCENT2].attributes[2] = 1;
13753 64 guysbuf[eMOLDORM].attributes[1] = 0;
13754 64 }
13755
13756
2/2
✓ Branch 0 taken 395 times.
✓ Branch 1 taken 82 times.
477 if ( Header->zelda_version < 0x211 ) //Default rest rates for phantom ghinis, peahats and keese in < 2.50 quests
13757 {
13758 82 guysbuf[eKEESE1].attributes[15] = 120;
13759 82 guysbuf[eKEESE2].attributes[15] = 120;
13760 82 guysbuf[eKEESE3].attributes[15] = 120;
13761 82 guysbuf[eKEESETRIB].attributes[15] = 120;
13762 82 guysbuf[eKEESE1].attributes[16] = 16;
13763 82 guysbuf[eKEESE2].attributes[16] = 16;
13764 82 guysbuf[eKEESE3].attributes[16] = 16;
13765 82 guysbuf[eKEESETRIB].attributes[16] = 16;
13766
13767 82 guysbuf[ePEAHAT].attributes[15] = 80;
13768 82 guysbuf[ePEAHAT].attributes[16] = 16;
13769
13770 82 guysbuf[eGHINI2].attributes[15] = 120;
13771 82 guysbuf[eGHINI2].attributes[16] = 10;
13772
13773
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 66 times.
82 if (replay_version_check(20))
13774 {
13775 66 guysbuf[eGHINI2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13776 66 guysbuf[eMOLDORM].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13777 66 guysbuf[eKEESETRIB].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13778 66 guysbuf[eKEESE3].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13779 66 guysbuf[eKEESE2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13780 66 guysbuf[eKEESE1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13781 66 guysbuf[eTEK1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13782 66 guysbuf[eTEK2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13783 66 guysbuf[ePEAHAT].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13784 66 guysbuf[eROCK].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13785 66 guysbuf[eTRAP].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13786 66 guysbuf[eWALLM].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13787 66 guysbuf[ePOLSV].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13788 66 guysbuf[eMANHAN].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13789 66 guysbuf[eGLEEOK1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13790 66 guysbuf[eGLEEOK2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13791 66 guysbuf[eGLEEOK3].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13792 66 guysbuf[eGLEEOK4].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13793 66 guysbuf[eDIG1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13794 66 guysbuf[eDIG3].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13795 66 guysbuf[eDIGPUP1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13796 66 guysbuf[eDIGPUP2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13797 66 guysbuf[eDIGPUP3].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13798 66 guysbuf[eDIGPUP4].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13799 66 guysbuf[eRAQUAM].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13800 66 guysbuf[eITEMFAIRY].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13801 66 guysbuf[eFIRE].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13802 66 guysbuf[eMANHAN2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13803 66 guysbuf[eTRAP_H].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13804 66 guysbuf[eTRAP_V].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13805 66 guysbuf[eTRAP_LR].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13806 66 guysbuf[eTRAP_UD].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13807 66 guysbuf[ePATRA1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13808 66 guysbuf[ePATRA2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13809 66 guysbuf[ePATRABS].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13810 66 guysbuf[eBAT].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13811 66 guysbuf[eGLEEOK1F].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13812 66 guysbuf[eGLEEOK2F].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13813 66 guysbuf[eGLEEOK3F].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13814 66 guysbuf[eGLEEOK4F].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13815 66 guysbuf[eTRIGGER].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13816 66 guysbuf[ePATRAL2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13817 66 guysbuf[ePATRAL3].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13818 66 guysbuf[eGOHMA1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13819 66 guysbuf[eGOHMA2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13820 66 guysbuf[eGOHMA3].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13821 66 guysbuf[eGOHMA4].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13822 66 guysbuf[eMPOLSV].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13823 66 guysbuf[eWPOLSV].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13824 66 }
13825 82 }
13826
13827
13828
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 395 times.
477 if(guyversion<=2)
13829 {
13830 82 return readherosprites2(f, guyversion==2?0:-1);
13831 }
13832
13833
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 395 times.
395 if(guyversion > 3)
13834 {
13835 guydata tempguy;
13836
13837
2/2
✓ Branch 0 taken 202240 times.
✓ Branch 1 taken 395 times.
202635 for(int32_t i=0; i<MAXGUYS; i++)
13838 {
13839
1/2
✓ Branch 0 taken 202240 times.
✗ Branch 1 not taken.
202240 if(guyversion < 23) // May 2012 : 512 max enemies
13840 {
13841 if(i >= OLDBETAMAXGUYS)
13842 {
13843 memset(&guysbuf[i], 0, sizeof(guydata));
13844 continue;
13845 }
13846 }
13847
13848 202240 memset(&tempguy, 0, sizeof(guydata));
13849
13850 uint32_t flags1;
13851 uint32_t flags2;
13852
1/2
✓ Branch 0 taken 202240 times.
✗ Branch 1 not taken.
202240 if(!p_igetl(&(flags1),f))
13853 {
13854 return qe_invalid;
13855 }
13856
1/2
✓ Branch 0 taken 202240 times.
✗ Branch 1 not taken.
202240 if(!p_igetl(&(flags2),f))
13857 {
13858 return qe_invalid;
13859 }
13860 202240 tempguy.flags = guy_flags(flags1) | guy_flags(uint64_t(flags2)<<32ULL);
13861
13862
2/2
✓ Branch 0 taken 97280 times.
✓ Branch 1 taken 104960 times.
202240 if ( guyversion >= 36 ) //expanded tiles
13863 {
13864
1/2
✓ Branch 0 taken 97280 times.
✗ Branch 1 not taken.
97280 if(!p_igetl(&(tempguy.tile),f))
13865 {
13866 return qe_invalid;
13867 }
13868 97280 }
13869 else
13870 {
13871
1/2
✓ Branch 0 taken 104960 times.
✗ Branch 1 not taken.
104960 if(!p_igetw(&(tempguy.tile),f))
13872 {
13873 return qe_invalid;
13874 }
13875 }
13876
1/2
✓ Branch 0 taken 202240 times.
✗ Branch 1 not taken.
202240 if(!p_getc(&(tempguy.width),f))
13877 {
13878 return qe_invalid;
13879 }
13880
13881
1/2
✓ Branch 0 taken 202240 times.
✗ Branch 1 not taken.
202240 if(!p_getc(&(tempguy.height),f))
13882 {
13883 return qe_invalid;
13884 }
13885
13886
2/2
✓ Branch 0 taken 97280 times.
✓ Branch 1 taken 104960 times.
202240 if ( guyversion >= 36 ) //expanded tiles
13887 {
13888
1/2
✓ Branch 0 taken 97280 times.
✗ Branch 1 not taken.
97280 if(!p_igetl(&(tempguy.s_tile),f))
13889 {
13890 return qe_invalid;
13891 }
13892 97280 }
13893 else
13894 {
13895
1/2
✓ Branch 0 taken 104960 times.
✗ Branch 1 not taken.
104960 if(!p_igetw(&(tempguy.s_tile),f))
13896 {
13897 return qe_invalid;
13898 }
13899 }
13900
13901
1/2
✓ Branch 0 taken 202240 times.
✗ Branch 1 not taken.
202240 if(!p_getc(&(tempguy.s_width),f))
13902 {
13903 return qe_invalid;
13904 }
13905
13906
1/2
✓ Branch 0 taken 202240 times.
✗ Branch 1 not taken.
202240 if(!p_getc(&(tempguy.s_height),f))
13907 {
13908 return qe_invalid;
13909 }
13910
13911
2/2
✓ Branch 0 taken 97280 times.
✓ Branch 1 taken 104960 times.
202240 if ( guyversion >= 36 ) //expanded tiles
13912 {
13913
1/2
✓ Branch 0 taken 97280 times.
✗ Branch 1 not taken.
97280 if(!p_igetl(&(tempguy.e_tile),f))
13914 {
13915 return qe_invalid;
13916 }
13917 97280 }
13918 else
13919 {
13920
1/2
✓ Branch 0 taken 104960 times.
✗ Branch 1 not taken.
104960 if(!p_igetw(&(tempguy.e_tile),f))
13921 {
13922 return qe_invalid;
13923 }
13924 }
13925
13926
1/2
✓ Branch 0 taken 202240 times.
✗ Branch 1 not taken.
202240 if(!p_getc(&(tempguy.e_width),f))
13927 {
13928 return qe_invalid;
13929 }
13930
13931
1/2
✓ Branch 0 taken 202240 times.
✗ Branch 1 not taken.
202240 if(!p_getc(&(tempguy.e_height),f))
13932 {
13933 return qe_invalid;
13934 }
13935
13936
1/2
✓ Branch 0 taken 202240 times.
✗ Branch 1 not taken.
202240 if(!p_igetw(&(tempguy.hp),f))
13937 {
13938 return qe_invalid;
13939 }
13940
13941
1/2
✓ Branch 0 taken 202240 times.
✗ Branch 1 not taken.
202240 if(!p_igetw(&(tempguy.family),f))
13942 {
13943 return qe_invalid;
13944 }
13945
13946
1/12
✗ Branch 0 not taken.
✓ Branch 1 taken 202240 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
202240 if(guyversion < 9 && (i==eDKNUT1 || i==eDKNUT2 || i==eDKNUT3 || i==eDKNUT4 || i==eDKNUT5)) // Whoops, forgot about Darknuts...
13947 {
13948 if(get_qr(qr_NEWENEMYTILES))
13949 {
13950 tempguy.s_tile=tempguy.e_tile+120;
13951 tempguy.s_width=tempguy.e_width;
13952 tempguy.s_height=tempguy.e_height;
13953 }
13954 else tempguy.s_tile=860;
13955 }
13956
13957
1/2
✓ Branch 0 taken 202240 times.
✗ Branch 1 not taken.
202240 if(!p_igetw(&(tempguy.cset),f))
13958 {
13959 return qe_invalid;
13960 }
13961
13962
1/2
✓ Branch 0 taken 202240 times.
✗ Branch 1 not taken.
202240 if(!p_igetw(&(tempguy.anim),f))
13963 {
13964 return qe_invalid;
13965 }
13966
13967
1/2
✓ Branch 0 taken 202240 times.
✗ Branch 1 not taken.
202240 if(!p_igetw(&(tempguy.e_anim),f))
13968 {
13969 return qe_invalid;
13970 }
13971
13972
1/2
✓ Branch 0 taken 202240 times.
✗ Branch 1 not taken.
202240 if(!p_igetw(&(tempguy.frate),f))
13973 {
13974 return qe_invalid;
13975 }
13976
13977
1/2
✓ Branch 0 taken 202240 times.
✗ Branch 1 not taken.
202240 if(!p_igetw(&(tempguy.e_frate),f))
13978 {
13979 return qe_invalid;
13980 }
13981
13982
1/2
✓ Branch 0 taken 202240 times.
✗ Branch 1 not taken.
202240 if(guyversion < 13) // April 2009
13983 {
13984 if(get_bit(deprecated_rules, qr_SLOWENEMYANIM_DEP))
13985 {
13986 tempguy.frate *= 2;
13987 tempguy.e_frate *= 2;
13988 }
13989 }
13990
13991
1/2
✓ Branch 0 taken 202240 times.
✗ Branch 1 not taken.
202240 if(guyversion < 14) // May 1 2009
13992 {
13993 if(tempguy.anim==a2FRMSLOW)
13994 {
13995 tempguy.anim=a2FRM;
13996 tempguy.frate *= 2;
13997 }
13998
13999 if(tempguy.e_anim==a2FRMSLOW)
14000 {
14001 tempguy.e_anim=a2FRM;
14002 tempguy.e_frate *= 2;
14003 }
14004
14005 if(tempguy.anim==aFLIPSLOW)
14006 {
14007 tempguy.anim=aFLIP;
14008 tempguy.frate *= 2;
14009 }
14010
14011 if(tempguy.e_anim==aFLIPSLOW)
14012 {
14013 tempguy.e_anim=aFLIP;
14014 tempguy.e_frate *= 2;
14015 }
14016
14017 if(tempguy.anim == aNEWDWALK) tempguy.anim = a4FRM4DIR;
14018
14019 if(tempguy.e_anim == aNEWDWALK) tempguy.e_anim = a4FRM4DIR;
14020
14021 if(tempguy.anim == aNEWPOLV || tempguy.anim == a4FRM3TRAP)
14022 {
14023 tempguy.anim=a4FRM4DIR;
14024 tempguy.s_tile=(get_qr(qr_NEWENEMYTILES) ? tempguy.e_tile : tempguy.tile)+20;
14025 }
14026
14027 if(tempguy.e_anim == aNEWPOLV || tempguy.e_anim == a4FRM3TRAP)
14028 {
14029 tempguy.e_anim=a4FRM4DIR;
14030 tempguy.s_tile=(get_qr(qr_NEWENEMYTILES) ? tempguy.e_tile : tempguy.tile)+20;
14031 }
14032 }
14033
14034
1/2
✓ Branch 0 taken 202240 times.
✗ Branch 1 not taken.
202240 if(!p_igetw(&(tempguy.dp),f))
14035 {
14036 return qe_invalid;
14037 }
14038
14039 //correction for guy fire
14040
1/2
✓ Branch 0 taken 202240 times.
✗ Branch 1 not taken.
202240 if(guyversion < 6)
14041 {
14042 if(i == gFIRE)
14043 tempguy.dp = 2;
14044 }
14045
14046
1/2
✓ Branch 0 taken 202240 times.
✗ Branch 1 not taken.
202240 if(!p_igetw(&(tempguy.wdp),f))
14047 {
14048 return qe_invalid;
14049 }
14050
14051
1/2
✓ Branch 0 taken 202240 times.
✗ Branch 1 not taken.
202240 if(!p_igetw(&(tempguy.weapon),f))
14052 {
14053 return qe_invalid;
14054 }
14055
14056 //correction for bosses using triple, "rising" fireballs
14057
1/2
✓ Branch 0 taken 202240 times.
✗ Branch 1 not taken.
202240 if(guyversion < 5)
14058 {
14059 if(i == eLAQUAM || i == eRAQUAM || i == eGOHMA1 || i == eGOHMA2 ||
14060 i == eGOHMA3 || i == eGOHMA4)
14061 {
14062 if(tempguy.weapon == ewFireball)
14063 tempguy.weapon = ewFireball2;
14064 }
14065 }
14066
14067
1/2
✓ Branch 0 taken 202240 times.
✗ Branch 1 not taken.
202240 if(!p_igetw(&(tempguy.rate),f))
14068 {
14069 return qe_invalid;
14070 }
14071
14072
1/2
✓ Branch 0 taken 202240 times.
✗ Branch 1 not taken.
202240 if(!p_igetw(&(tempguy.hrate),f))
14073 {
14074 return qe_invalid;
14075 }
14076
14077
1/2
✓ Branch 0 taken 202240 times.
✗ Branch 1 not taken.
202240 if(!p_igetw(&(tempguy.step),f))
14078 {
14079 return qe_invalid;
14080 }
14081
14082 // HIGHLY UNORTHODOX UPDATING THING, part 2
14083
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 202240 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
202240 if(fixpolsvoice && tempguy.family==eePOLSV)
14084 {
14085 tempguy.step /= 2;
14086 }
14087
14088
1/2
✓ Branch 0 taken 202240 times.
✗ Branch 1 not taken.
202240 if(!p_igetw(&(tempguy.homing),f))
14089 {
14090 return qe_invalid;
14091 }
14092
14093
1/2
✓ Branch 0 taken 202240 times.
✗ Branch 1 not taken.
202240 if(!p_igetw(&(tempguy.grumble),f))
14094 {
14095 return qe_invalid;
14096 }
14097
14098
1/2
✓ Branch 0 taken 202240 times.
✗ Branch 1 not taken.
202240 if(!p_igetw(&(tempguy.item_set),f))
14099 {
14100 return qe_invalid;
14101 }
14102
14103
1/2
✓ Branch 0 taken 202240 times.
✗ Branch 1 not taken.
202240 if(guyversion>=22) // Version 22: Expand misc attributes to 32 bits
14104 {
14105
2/2
✓ Branch 0 taken 2022400 times.
✓ Branch 1 taken 202240 times.
2224640 for (int q = 0; q < 10; ++q)
14106 {
14107
1/2
✓ Branch 0 taken 2022400 times.
✗ Branch 1 not taken.
2022400 if (!p_igetl(&(tempguy.attributes[q]), f))
14108 {
14109 return qe_invalid;
14110 }
14111 2022400 }
14112 202240 }
14113 else
14114 {
14115 int16_t tempMisc;
14116
14117 for(int q=0;q<10;q++)
14118 {
14119 if (!p_igetw(&tempMisc, f))
14120 {
14121 return qe_invalid;
14122 }
14123 tempguy.attributes[q] = tempMisc;
14124 }
14125
14126 if(guyversion < 13) // April 2009 - a tiny Wizzrobe update
14127 {
14128 if(tempguy.family == eeWIZZ && !(tempguy.attributes[0]))
14129 tempguy.attributes[4] = 74;
14130 }
14131
14132 }
14133
14134
1/2
✓ Branch 0 taken 202240 times.
✗ Branch 1 not taken.
202240 if(!p_igetw(&(tempguy.bgsfx),f))
14135 {
14136 return qe_invalid;
14137 }
14138
14139
1/2
✓ Branch 0 taken 202240 times.
✗ Branch 1 not taken.
202240 if(!p_igetw(&(tempguy.bosspal),f))
14140 {
14141 return qe_invalid;
14142 }
14143
14144
1/2
✓ Branch 0 taken 202240 times.
✗ Branch 1 not taken.
202240 if(!p_igetw(&(tempguy.extend),f))
14145 {
14146 return qe_invalid;
14147 }
14148
14149 //! Enemy Defences
14150
14151 //If a 2.50 quest, use only the 2.5 defences.
14152
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 202240 times.
202240 if(guyversion >= 16 ) // November 2009 - Super Enemy Editor
14153 {
14154
2/2
✓ Branch 0 taken 3842560 times.
✓ Branch 1 taken 202240 times.
4044800 for(int32_t j=0; j<edefLAST; j++)
14155 {
14156
1/2
✓ Branch 0 taken 3842560 times.
✗ Branch 1 not taken.
3842560 if(!p_getc(&(tempguy.defense[j]),f))
14157 {
14158 return qe_invalid;
14159 }
14160 3842560 }
14161 //then copy the generic script defence to all the new script defences
14162
14163 202240 }
14164
14165
14166
14167
14168
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 202240 times.
202240 if(guyversion >= 18)
14169 {
14170
1/2
✓ Branch 0 taken 202240 times.
✗ Branch 1 not taken.
202240 if(!p_getc(&(tempguy.hitsfx),f))
14171 {
14172 return qe_invalid;
14173 }
14174
14175
1/2
✓ Branch 0 taken 202240 times.
✗ Branch 1 not taken.
202240 if(!p_getc(&(tempguy.deadsfx),f))
14176 {
14177 return qe_invalid;
14178 }
14179 202240 }
14180
14181
1/2
✓ Branch 0 taken 202240 times.
✗ Branch 1 not taken.
202240 if(guyversion >= 22)
14182 {
14183
1/2
✓ Branch 0 taken 202240 times.
✗ Branch 1 not taken.
202240 if(!p_igetl(&(tempguy.attributes[10]), f))
14184 {
14185 return qe_invalid;
14186 }
14187
14188
1/2
✓ Branch 0 taken 202240 times.
✗ Branch 1 not taken.
202240 if(!p_igetl(&(tempguy.attributes[11]),f))
14189 {
14190 return qe_invalid;
14191 }
14192 202240 }
14193 else if(guyversion >= 19)
14194 {
14195 int16_t tempMisc;
14196
14197 if(!p_igetw(&tempMisc,f))
14198 {
14199 return qe_invalid;
14200 }
14201
14202 tempguy.attributes[10] = tempMisc;
14203
14204 if(!p_igetw(&tempMisc,f))
14205 {
14206 return qe_invalid;
14207 }
14208
14209 tempguy.attributes[11] = tempMisc;
14210 }
14211
14212 //If a 2.54 or later quest, use all of the defences.
14213
2/2
✓ Branch 0 taken 104960 times.
✓ Branch 1 taken 97280 times.
202240 if(guyversion > 24) // Add new guyversion conditional statement
14214 {
14215
2/2
✓ Branch 0 taken 2140160 times.
✓ Branch 1 taken 97280 times.
2237440 for(int32_t j=edefLAST; j<edefLAST255; j++)
14216 {
14217
1/2
✓ Branch 0 taken 2140160 times.
✗ Branch 1 not taken.
2140160 if(!p_getc(&(tempguy.defense[j]),f))
14218 {
14219 return qe_invalid;
14220 }
14221 2140160 }
14222 97280 }
14223
14224
2/2
✓ Branch 0 taken 97280 times.
✓ Branch 1 taken 104960 times.
202240 if(guyversion <= 24) // Port over generic script settings from old quests in the new editor.
14225 {
14226
2/2
✓ Branch 0 taken 1049600 times.
✓ Branch 1 taken 104960 times.
1154560 for(int32_t j=edefSCRIPT01; j<=edefSCRIPT10; j++)
14227 {
14228 1049600 tempguy.defense[j] = tempguy.defense[edefSCRIPT] ;
14229 1049600 }
14230 104960 }
14231
14232 //tilewidth, tileheight, hitwidth, hitheight, hitzheight, hitxofs, hityofs, hitzofs
14233
2/2
✓ Branch 0 taken 104960 times.
✓ Branch 1 taken 97280 times.
202240 if(guyversion > 25)
14234 {
14235
1/2
✓ Branch 0 taken 97280 times.
✗ Branch 1 not taken.
97280 if(!p_igetl(&(tempguy.txsz),f))
14236 {
14237 return qe_invalid;
14238 }
14239
1/2
✓ Branch 0 taken 97280 times.
✗ Branch 1 not taken.
97280 if(!p_igetl(&(tempguy.tysz),f))
14240 {
14241 return qe_invalid;
14242 }
14243
1/2
✓ Branch 0 taken 97280 times.
✗ Branch 1 not taken.
97280 if(!p_igetl(&(tempguy.hxsz),f))
14244 {
14245 return qe_invalid;
14246 }
14247
1/2
✓ Branch 0 taken 97280 times.
✗ Branch 1 not taken.
97280 if(!p_igetl(&(tempguy.hysz),f))
14248 {
14249 return qe_invalid;
14250 }
14251
1/2
✓ Branch 0 taken 97280 times.
✗ Branch 1 not taken.
97280 if(!p_igetl(&(tempguy.hzsz),f))
14252 {
14253 return qe_invalid;
14254 }
14255 /* Is it safe to read a fixed with getl, or do I need to typecast it? -Z
14256
14257 */
14258 97280 }
14259 //More Enemy Editor vars for 2.60
14260
2/2
✓ Branch 0 taken 104960 times.
✓ Branch 1 taken 97280 times.
202240 if(guyversion > 26)
14261 {
14262
1/2
✓ Branch 0 taken 97280 times.
✗ Branch 1 not taken.
97280 if(!p_igetl(&(tempguy.hxofs),f))
14263 {
14264 return qe_invalid;
14265 }
14266
1/2
✓ Branch 0 taken 97280 times.
✗ Branch 1 not taken.
97280 if(!p_igetl(&(tempguy.hyofs),f))
14267 {
14268 return qe_invalid;
14269 }
14270
1/2
✓ Branch 0 taken 97280 times.
✗ Branch 1 not taken.
97280 if(!p_igetl(&(tempguy.xofs),f))
14271 {
14272 return qe_invalid;
14273 }
14274
1/2
✓ Branch 0 taken 97280 times.
✗ Branch 1 not taken.
97280 if(!p_igetl(&(tempguy.yofs),f))
14275 {
14276 return qe_invalid;
14277 }
14278
1/2
✓ Branch 0 taken 97280 times.
✗ Branch 1 not taken.
97280 if(!p_igetl(&(tempguy.zofs),f))
14279 {
14280 return qe_invalid;
14281 }
14282 97280 }
14283
14284
2/2
✓ Branch 0 taken 97280 times.
✓ Branch 1 taken 104960 times.
202240 if(guyversion <= 27) // Port over generic script settings from old quests in the new editor.
14285 {
14286 104960 tempguy.wpnsprite = 0;
14287 104960 }
14288
14289
2/2
✓ Branch 0 taken 104960 times.
✓ Branch 1 taken 97280 times.
202240 if(guyversion > 27)
14290 {
14291
1/2
✓ Branch 0 taken 97280 times.
✗ Branch 1 not taken.
97280 if(!p_igetl(&(tempguy.wpnsprite),f))
14292 {
14293 return qe_invalid;
14294 }
14295 97280 }
14296
2/2
✓ Branch 0 taken 97280 times.
✓ Branch 1 taken 104960 times.
202240 if(guyversion <= 28) // Port over generic script settings from old quests in the new editor.
14297 {
14298 104960 tempguy.SIZEflags = 0;
14299 104960 }
14300
2/2
✓ Branch 0 taken 104960 times.
✓ Branch 1 taken 97280 times.
202240 if(guyversion > 28)
14301 {
14302
1/2
✓ Branch 0 taken 97280 times.
✗ Branch 1 not taken.
97280 if(!p_igetl(&(tempguy.SIZEflags),f))
14303 {
14304 return qe_invalid;
14305 }
14306
14307 97280 }
14308
2/2
✓ Branch 0 taken 97280 times.
✓ Branch 1 taken 104960 times.
202240 if(guyversion < 30) // Port over generic script settings from old quests in the new editor.
14309 {
14310 104960 tempguy.frozentile = 0;
14311 104960 tempguy.frozencset = 0;
14312 104960 tempguy.frozenclock = 0;
14313
2/2
✓ Branch 0 taken 1049600 times.
✓ Branch 1 taken 104960 times.
1154560 for ( int32_t q = 0; q < 10; q++ ) tempguy.frozenmisc[q] = 0;
14314 104960 }
14315
2/2
✓ Branch 0 taken 104960 times.
✓ Branch 1 taken 97280 times.
202240 if(guyversion >= 30)
14316 {
14317
1/2
✓ Branch 0 taken 97280 times.
✗ Branch 1 not taken.
97280 if(!p_igetl(&(tempguy.frozentile),f))
14318 {
14319 return qe_invalid;
14320 }
14321
1/2
✓ Branch 0 taken 97280 times.
✗ Branch 1 not taken.
97280 if(!p_igetl(&(tempguy.frozencset),f))
14322 {
14323 return qe_invalid;
14324 }
14325
1/2
✓ Branch 0 taken 97280 times.
✗ Branch 1 not taken.
97280 if(!p_igetl(&(tempguy.frozenclock),f))
14326 {
14327 return qe_invalid;
14328 }
14329
2/2
✓ Branch 0 taken 972800 times.
✓ Branch 1 taken 97280 times.
1070080 for ( int32_t q = 0; q < 10; q++ ) {
14330
1/2
✓ Branch 0 taken 972800 times.
✗ Branch 1 not taken.
972800 if(!p_igetw(&(tempguy.frozenmisc[q]),f))
14331 {
14332 return qe_invalid;
14333 }
14334 972800 }
14335
14336 97280 }
14337
14338
2/2
✓ Branch 0 taken 104960 times.
✓ Branch 1 taken 97280 times.
202240 if(guyversion >= 34)
14339 {
14340
1/2
✓ Branch 0 taken 97280 times.
✗ Branch 1 not taken.
97280 if(!p_igetw(&(tempguy.firesfx),f))
14341 {
14342 return qe_invalid;
14343 }
14344
2/2
✓ Branch 0 taken 1653760 times.
✓ Branch 1 taken 97280 times.
1751040 for(int q=15;q<32;++q)
14345 {
14346
1/2
✓ Branch 0 taken 1653760 times.
✗ Branch 1 not taken.
1653760 if(!p_igetl(&(tempguy.attributes[q]),f))
14347 {
14348 return qe_invalid;
14349 }
14350 1653760 }
14351
14352
2/2
✓ Branch 0 taken 3112960 times.
✓ Branch 1 taken 97280 times.
3210240 for ( int32_t q = 0; q < 32; q++ ) {
14353
1/2
✓ Branch 0 taken 3112960 times.
✗ Branch 1 not taken.
3112960 if(!p_igetl(&(tempguy.movement[q]),f))
14354 {
14355 return qe_invalid;
14356 }
14357 3112960 }
14358
2/2
✓ Branch 0 taken 3112960 times.
✓ Branch 1 taken 97280 times.
3210240 for ( int32_t q = 0; q < 32; q++ ) {
14359
1/2
✓ Branch 0 taken 3112960 times.
✗ Branch 1 not taken.
3112960 if(!p_igetl(&(tempguy.new_weapon[q]),f))
14360 {
14361 return qe_invalid;
14362 }
14363 3112960 }
14364
1/2
✓ Branch 0 taken 97280 times.
✗ Branch 1 not taken.
97280 if(!p_igetw(&(tempguy.script),f))
14365 {
14366 return qe_invalid;
14367 }
14368
2/2
✓ Branch 0 taken 778240 times.
✓ Branch 1 taken 97280 times.
875520 for ( int32_t q = 0; q < 8; q++ )
14369 {
14370
1/2
✓ Branch 0 taken 778240 times.
✗ Branch 1 not taken.
778240 if(!p_igetl(&(tempguy.initD[q]),f))
14371 {
14372 return qe_invalid;
14373 }
14374 778240 }
14375
2/2
✓ Branch 0 taken 194560 times.
✓ Branch 1 taken 97280 times.
291840 for ( int32_t q = 0; q < 2; q++ )
14376 {
14377 int32_t temp;
14378
1/2
✓ Branch 0 taken 194560 times.
✗ Branch 1 not taken.
194560 if(!p_igetl(&temp,f))
14379 {
14380 return qe_invalid;
14381 }
14382 194560 }
14383
14384 97280 }
14385
14386
2/2
✓ Branch 0 taken 104960 times.
✓ Branch 1 taken 97280 times.
202240 if(guyversion >= 37)
14387 {
14388
1/2
✓ Branch 0 taken 97280 times.
✗ Branch 1 not taken.
97280 if(!p_igetl(&(tempguy.editorflags),f))
14389 {
14390 return qe_invalid;
14391 }
14392 97280 }
14393
2/2
✓ Branch 0 taken 97280 times.
✓ Branch 1 taken 104960 times.
202240 if ( guyversion < 37 ) { tempguy.editorflags = 0; }
14394
2/2
✓ Branch 0 taken 104960 times.
✓ Branch 1 taken 97280 times.
202240 if(guyversion >= 38)
14395 {
14396
1/2
✓ Branch 0 taken 97280 times.
✗ Branch 1 not taken.
97280 if(!p_igetl(&(tempguy.attributes[12]),f))
14397 {
14398 return qe_invalid;
14399 }
14400
1/2
✓ Branch 0 taken 97280 times.
✗ Branch 1 not taken.
97280 if(!p_igetl(&(tempguy.attributes[13]),f))
14401 {
14402 return qe_invalid;
14403 }
14404
1/2
✓ Branch 0 taken 97280 times.
✗ Branch 1 not taken.
97280 if(!p_igetl(&(tempguy.attributes[14]),f))
14405 {
14406 return qe_invalid;
14407 }
14408
14409 97280 }
14410
2/2
✓ Branch 0 taken 97280 times.
✓ Branch 1 taken 104960 times.
202240 if ( guyversion < 38 )
14411 {
14412 104960 tempguy.attributes[12] = 0;
14413 104960 tempguy.attributes[13] = 0;
14414 104960 tempguy.attributes[14] = 0;
14415 104960 }
14416
14417
2/2
✓ Branch 0 taken 104960 times.
✓ Branch 1 taken 97280 times.
202240 if ( guyversion >= 39 )
14418 {
14419
2/2
✓ Branch 0 taken 778240 times.
✓ Branch 1 taken 97280 times.
875520 for ( int32_t q = 0; q < 8; q++ )
14420 {
14421
2/2
✓ Branch 0 taken 50585600 times.
✓ Branch 1 taken 778240 times.
51363840 for ( int32_t w = 0; w < 65; w++ )
14422 {
14423
1/2
✓ Branch 0 taken 50585600 times.
✗ Branch 1 not taken.
50585600 if(!p_getc(&(tempguy.initD_label[q][w]),f))
14424 {
14425 return qe_invalid;
14426 }
14427 50585600 }
14428
2/2
✓ Branch 0 taken 50585600 times.
✓ Branch 1 taken 778240 times.
51363840 for ( int32_t w = 0; w < 65; w++ )
14429 {
14430
1/2
✓ Branch 0 taken 50585600 times.
✗ Branch 1 not taken.
50585600 if(!p_getc(&(tempguy.weapon_initD_label[q][w]),f))
14431 {
14432 return qe_invalid;
14433 }
14434 50585600 }
14435 778240 }
14436
14437
14438 97280 }
14439
2/2
✓ Branch 0 taken 97280 times.
✓ Branch 1 taken 104960 times.
202240 if ( guyversion < 39 ) //apply old InitD strings to both
14440 {
14441
2/2
✓ Branch 0 taken 839680 times.
✓ Branch 1 taken 104960 times.
944640 for ( int32_t q = 0; q < 8; q++ )
14442 {
14443 839680 sprintf(tempguy.initD_label[q],"InitD[%d]",q);
14444 839680 sprintf(tempguy.weapon_initD_label[q],"InitD[%d]",q);
14445 839680 }
14446 104960 }
14447
2/2
✓ Branch 0 taken 104960 times.
✓ Branch 1 taken 97280 times.
202240 if ( guyversion >= 40 )
14448 {
14449
1/2
✓ Branch 0 taken 97280 times.
✗ Branch 1 not taken.
97280 if(!p_igetw(&(tempguy.weaponscript),f))
14450 {
14451 return qe_invalid;
14452 }
14453 97280 }
14454
2/2
✓ Branch 0 taken 97280 times.
✓ Branch 1 taken 104960 times.
202240 if ( guyversion < 40 )
14455 {
14456 104960 tempguy.weaponscript = 0;
14457 104960 }
14458 //eweapon script InitD
14459
2/2
✓ Branch 0 taken 104960 times.
✓ Branch 1 taken 97280 times.
202240 if ( guyversion >= 41 )
14460 {
14461
2/2
✓ Branch 0 taken 778240 times.
✓ Branch 1 taken 97280 times.
875520 for ( int32_t q = 0; q < 8; q++ )
14462 {
14463
1/2
✓ Branch 0 taken 778240 times.
✗ Branch 1 not taken.
778240 if(!p_igetl(&(tempguy.weap_initiald[q]),f))
14464 {
14465 return qe_invalid;
14466 }
14467 778240 }
14468
1/2
✓ Branch 0 taken 97280 times.
✗ Branch 1 not taken.
97280 if ( guy_cversion < 4 )
14469 {
14470 if ( tempguy.family == eeKEESE )
14471 {
14472
14473 if ( !tempguy.attributes[0] )
14474 {
14475 tempguy.attributes[15] = 120;
14476 tempguy.attributes[16] = 16;
14477
14478 }
14479 }
14480 if ( tempguy.family == eePEAHAT )
14481 {
14482 tempguy.attributes[15] = 80;
14483 tempguy.attributes[16] = 16;
14484 }
14485
14486 if ( tempguy.family == eeGHINI )
14487 {
14488 tempguy.attributes[15] = 120;
14489 tempguy.attributes[16] = 10;
14490 }
14491
14492 }
14493 97280 }
14494
14495
14496
14497 //default weapon sprites (quest version < 2.54)
14498 //port over old defaults -Z
14499
2/2
✓ Branch 0 taken 97280 times.
✓ Branch 1 taken 104960 times.
202240 if(guyversion < 32)
14500 {
14501
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104960 times.
104960 if ( tempguy.wpnsprite <= 0 )
14502 {
14503
16/20
✗ Branch 0 not taken.
✓ Branch 1 taken 2911 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 89121 times.
✓ Branch 4 taken 817 times.
✓ Branch 5 taken 708 times.
✓ Branch 6 taken 1938 times.
✓ Branch 7 taken 1316 times.
✓ Branch 8 taken 2445 times.
✓ Branch 9 taken 211 times.
✓ Branch 10 taken 78 times.
✓ Branch 11 taken 457 times.
✓ Branch 12 taken 79 times.
✓ Branch 13 taken 924 times.
✓ Branch 14 taken 1849 times.
✓ Branch 15 taken 234 times.
✓ Branch 16 taken 332 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 1540 times.
104960 switch(tempguy.weapon)
14504 {
14505 case wNone:
14506 89121 tempguy.wpnsprite = 0; break;
14507
14508 case wSword:
14509 case wBeam:
14510 case wBrang:
14511 case wBomb:
14512 case wSBomb:
14513 case wLitBomb:
14514 case wLitSBomb:
14515 case wArrow:
14516 case wFire:
14517 case wWhistle:
14518 case wBait:
14519 case wWand:
14520 case wMagic:
14521 case wCatching:
14522 case wWind:
14523 case wRefMagic:
14524 case wRefFireball:
14525 case wRefRock:
14526 case wHammer:
14527 case wHookshot:
14528 case wHSHandle:
14529 case wHSChain:
14530 case wSSparkle:
14531 case wFSparkle:
14532 case wSmack:
14533 case wPhantom:
14534 case wCByrna:
14535 case wRefBeam:
14536 case wStomp:
14537 case lwMax:
14538 case wScript1:
14539 case wScript2:
14540 case wScript3:
14541 case wScript4:
14542 case wScript5:
14543 case wScript6:
14544 case wScript7:
14545 case wScript8:
14546 case wScript9:
14547 case wScript10:
14548 case wIce:
14549 //Cannot use any of these weapons yet.
14550 tempguy.wpnsprite = -1;
14551 break;
14552
14553 case wEnemyWeapons:
14554 2911 case ewFireball: tempguy.wpnsprite = 17; break;
14555
14556 817 case ewArrow: tempguy.wpnsprite = 19; break;
14557 708 case ewBrang: tempguy.wpnsprite = 4; break;
14558 1938 case ewSword: tempguy.wpnsprite = 20; break;
14559 1316 case ewRock: tempguy.wpnsprite = 18; break;
14560 2445 case ewMagic: tempguy.wpnsprite = 21; break;
14561 211 case ewBomb: tempguy.wpnsprite = 78; break;
14562 78 case ewSBomb: tempguy.wpnsprite = 79; break;
14563 457 case ewLitBomb: tempguy.wpnsprite = 76; break;
14564 79 case ewLitSBomb: tempguy.wpnsprite = 77; break;
14565 924 case ewFireTrail: tempguy.wpnsprite = 80; break;
14566 1849 case ewFlame: tempguy.wpnsprite = 35; break;
14567 234 case ewWind: tempguy.wpnsprite = 36; break;
14568 332 case ewFlame2: tempguy.wpnsprite = 81; break;
14569 case ewFlame2Trail: tempguy.wpnsprite = 82; break;
14570 case ewIce: tempguy.wpnsprite = 83; break;
14571 1540 case ewFireball2: tempguy.wpnsprite = 17; break; //fireball (rising)
14572
14573
14574 default: break; //No assign.
14575 }
14576 104960 }
14577 104960 }
14578
14579 //default weapon fire sound (quest version < 2.54)
14580 //port over old defaults and zero new data. -Z
14581
2/2
✓ Branch 0 taken 97280 times.
✓ Branch 1 taken 104960 times.
202240 if(guyversion < 34)
14582 {
14583
2/2
✓ Branch 0 taken 3358720 times.
✓ Branch 1 taken 104960 times.
3463680 for ( int32_t q = 0; q < 32; q++ )
14584 {
14585 3358720 tempguy.movement[q] = 0;
14586 3358720 tempguy.new_weapon[q] = 0;
14587
14588 3358720 }
14589
14590 //NPC Script attributes.
14591 104960 tempguy.script = 0; //No scripted enemies existed. -Z
14592
2/2
✓ Branch 0 taken 839680 times.
✓ Branch 1 taken 104960 times.
944640 for ( int32_t q = 0; q < 8; q++ ) tempguy.initD[q] = 0; //Script Data
14593
14594
2/2
✓ Branch 0 taken 1784320 times.
✓ Branch 1 taken 104960 times.
1889280 for ( int32_t q = 15; q < 32; q++) tempguy.attributes[q] = 0; //misc 16-32
14595
14596 //old default sounds
14597
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104960 times.
104960 if ( tempguy.firesfx <= 0 )
14598 {
14599
16/20
✗ Branch 0 not taken.
✓ Branch 1 taken 2911 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 89121 times.
✓ Branch 4 taken 817 times.
✓ Branch 5 taken 708 times.
✓ Branch 6 taken 1938 times.
✓ Branch 7 taken 1316 times.
✓ Branch 8 taken 2445 times.
✓ Branch 9 taken 211 times.
✓ Branch 10 taken 78 times.
✓ Branch 11 taken 457 times.
✓ Branch 12 taken 79 times.
✓ Branch 13 taken 924 times.
✓ Branch 14 taken 1849 times.
✓ Branch 15 taken 234 times.
✓ Branch 16 taken 332 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 1540 times.
104960 switch(tempguy.weapon)
14600 {
14601 case wNone:
14602 89121 tempguy.firesfx = 0; break;
14603
14604 case wSword:
14605 case wBeam:
14606 case wBrang:
14607 case wBomb:
14608 case wSBomb:
14609 case wLitBomb:
14610 case wLitSBomb:
14611 case wArrow:
14612 case wFire:
14613 case wWhistle:
14614 case wBait:
14615 case wWand:
14616 case wMagic:
14617 case wCatching:
14618 case wWind:
14619 case wRefMagic:
14620 case wRefFireball:
14621 case wRefRock:
14622 case wHammer:
14623 case wHookshot:
14624 case wHSHandle:
14625 case wHSChain:
14626 case wSSparkle:
14627 case wFSparkle:
14628 case wSmack:
14629 case wPhantom:
14630 case wCByrna:
14631 case wRefBeam:
14632 case wStomp:
14633 case lwMax:
14634 case wScript1:
14635 case wScript2:
14636 case wScript3:
14637 case wScript4:
14638 case wScript5:
14639 case wScript6:
14640 case wScript7:
14641 case wScript8:
14642 case wScript9:
14643 case wScript10:
14644 case wIce:
14645 //Cannot use any of these weapons yet.
14646 tempguy.firesfx = -1;
14647 break;
14648
14649 case wEnemyWeapons:
14650 2911 case ewFireball: tempguy.firesfx = 40; break;
14651
14652 817 case ewArrow: tempguy.firesfx = 1; break; //Ghost.zh has 0?
14653 708 case ewBrang: tempguy.firesfx = 4; break; //Ghost.zh has 0?
14654 1938 case ewSword: tempguy.firesfx = 20; break; //Ghost.zh has 0?
14655 1316 case ewRock: tempguy.firesfx = 51; break;
14656 2445 case ewMagic: tempguy.firesfx = 32; break;
14657 211 case ewBomb: tempguy.firesfx = 3; break; //Ghost.zh has 0?
14658 78 case ewSBomb: tempguy.firesfx = 3; break; //Ghost.zh has 0?
14659 457 case ewLitBomb: tempguy.firesfx = 21; break; //Ghost.zh has 0?
14660 79 case ewLitSBomb: tempguy.firesfx = 21; break; //Ghost.zh has 0?
14661 924 case ewFireTrail: tempguy.firesfx = 13; break;
14662 1849 case ewFlame: tempguy.firesfx = 13; break;
14663 234 case ewWind: tempguy.firesfx = 32; break;
14664 332 case ewFlame2: tempguy.firesfx = 13; break;
14665 case ewFlame2Trail: tempguy.firesfx = 13; break;
14666 case ewIce: tempguy.firesfx = 44; break;
14667 1540 case ewFireball2: tempguy.firesfx = 40; break; //fireball (rising)
14668
14669 //what about special attacks (e.g. summoning == 56)
14670 default: break; //No assign.
14671 }
14672 104960 }
14673 104960 }
14674
14675 //Port hardcoded hit sound to the enemy hitsfx defaults for older quests.
14676
4/6
✓ Branch 0 taken 97280 times.
✓ Branch 1 taken 104960 times.
✓ Branch 2 taken 97280 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 97280 times.
202240 if(Header->zelda_version <= 0x250 || ( Header->zelda_version > 0x250 && guyversion < 35 ))
14677 {
14678
2/2
✓ Branch 0 taken 14184 times.
✓ Branch 1 taken 90776 times.
104960 if ( tempguy.hitsfx == 0 ) tempguy.hitsfx = 11;
14679 104960 }
14680 //Keese and bat halt rates.
14681
3/4
✓ Branch 0 taken 104960 times.
✓ Branch 1 taken 97280 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 104960 times.
202240 if ( guyversion < 42 && guy_cversion < 4 )
14682 {
14683
14684
2/2
✓ Branch 0 taken 103636 times.
✓ Branch 1 taken 1324 times.
104960 if ( tempguy.family == eeKEESE )
14685 {
14686
14687
2/2
✓ Branch 0 taken 369 times.
✓ Branch 1 taken 955 times.
1324 if ( !tempguy.attributes[0] )
14688 {
14689 955 tempguy.attributes[15] = 120;
14690 955 tempguy.attributes[16] = 16;
14691
14692 955 }
14693 1324 }
14694
2/2
✓ Branch 0 taken 104486 times.
✓ Branch 1 taken 474 times.
104960 if ( tempguy.family == eePEAHAT )
14695 {
14696 474 tempguy.attributes[15] = 80;
14697 474 tempguy.attributes[16] = 16;
14698 474 }
14699
2/2
✓ Branch 0 taken 104755 times.
✓ Branch 1 taken 205 times.
104960 if ( tempguy.family == eeGHINI )
14700 {
14701 205 tempguy.attributes[15] = 120;
14702 205 tempguy.attributes[16] = 10;
14703 205 }
14704
14705
14706 104960 }
14707
14708
14709 //miscellaneous other corrections
14710 //fix the mirror wizzrobe -DD
14711
1/2
✓ Branch 0 taken 202240 times.
✗ Branch 1 not taken.
202240 if(guyversion < 7)
14712 {
14713 if(i == eMWIZ)
14714 {
14715 tempguy.attributes[1] = 0;
14716 tempguy.attributes[3] = 1;
14717 }
14718 }
14719
14720
1/2
✓ Branch 0 taken 202240 times.
✗ Branch 1 not taken.
202240 if(guyversion < 8)
14721 {
14722 if(i == eGLEEOK1 || i == eGLEEOK2 || i == eGLEEOK3 || i == eGLEEOK4 || i == eGLEEOK1F || i == eGLEEOK2F || i == eGLEEOK3F || i == eGLEEOK4F)
14723 {
14724 // Some of these are deliberately different to NewDefault/defdata.cpp, by the way. -L
14725 tempguy.attributes[4] = 4; //neck length in segments
14726 tempguy.attributes[5] = 8; //neck offset from first body tile
14727 tempguy.attributes[6] = 40; //offset for each subsequent neck tile from the first neck tile
14728 tempguy.attributes[7] = 168; //head offset from first body tile
14729 tempguy.attributes[8] = 228; //flying head offset from first body tile
14730
14731 if(i == eGLEEOK1F || i == eGLEEOK2F || i == eGLEEOK3F || i == eGLEEOK4F)
14732 {
14733 tempguy.attributes[5] += 10; //neck offset from first body tile
14734 tempguy.attributes[7] -= 12; //head offset from first body tile
14735 }
14736 }
14737 }
14738
14739
1/2
✓ Branch 0 taken 202240 times.
✗ Branch 1 not taken.
202240 if(guyversion < 10) // December 2007 - Dodongo CSet fix
14740 {
14741 if(get_bit(deprecated_rules,46) && tempguy.family==eeDONGO && tempguy.attributes[0]==0)
14742 tempguy.bosspal = spDIG;
14743 }
14744
14745
1/2
✓ Branch 0 taken 202240 times.
✗ Branch 1 not taken.
202240 if(guyversion < 11) // December 2007 - Spinning Tile fix
14746 {
14747 if(tempguy.family==eeSPINTILE)
14748 {
14749 tempguy.flags |= guy_superman;
14750 tempguy.item_set = 0; // Don't drop items
14751 tempguy.step = 300;
14752 }
14753 }
14754
14755
1/2
✓ Branch 0 taken 202240 times.
✗ Branch 1 not taken.
202240 if(guyversion < 12) // October 2008 - Flashing Bubble, Rope 2, and Ghini 2 fix
14756 {
14757 if(get_bit(deprecated_rules, qr_NOROPE2FLASH_DEP))
14758 {
14759 if(tempguy.family==eeROPE)
14760 {
14761 tempguy.flags &= ~guy_flashing;
14762 }
14763 }
14764
14765 if(get_bit(deprecated_rules, qr_NOBUBBLEFLASH_DEP))
14766 {
14767 if(tempguy.family==eeBUBBLE)
14768 {
14769 tempguy.flags &= ~guy_flashing;
14770 }
14771 }
14772
14773 if((tempguy.family==eeGHINI)&&(tempguy.attributes[0]))
14774 {
14775 if(get_bit(deprecated_rules, qr_GHINI2BLINK_DEP))
14776 {
14777 tempguy.flags |= guy_blinking;
14778 }
14779
14780 if(get_bit(deprecated_rules, qr_PHANTOMGHINI2_DEP))
14781 {
14782 tempguy.flags |= guy_transparent;
14783 }
14784 }
14785 }
14786
14787
1/2
✓ Branch 0 taken 202240 times.
✗ Branch 1 not taken.
202240 if(guyversion < 15) // July 2009 - Guy Fire and Fairy fix
14788 {
14789 if(i==gFIRE)
14790 {
14791 tempguy.e_anim = aFLIP;
14792 tempguy.e_frate = 24;
14793 }
14794
14795 if(i==gFAIRY)
14796 {
14797 tempguy.e_anim = a2FRM;
14798 tempguy.e_frate = 16;
14799 }
14800 }
14801
14802
1/2
✓ Branch 0 taken 202240 times.
✗ Branch 1 not taken.
202240 if(guyversion < 16) // November 2009 - Super Enemy Editor part 1
14803 {
14804 if(i==0) Z_message("Updating guys to version 16...\n");
14805
14806 update_guy_1(&tempguy);
14807
14808 if(i==eMPOLSV)
14809 {
14810 tempguy.defense[edefARROW] = edCHINK;
14811 tempguy.defense[edefMAGIC] = ed1HKO;
14812 tempguy.defense[edefREFMAGIC] = ed1HKO;
14813 }
14814 }
14815
14816
1/2
✓ Branch 0 taken 202240 times.
✗ Branch 1 not taken.
202240 if(guyversion < 17) // December 2009
14817 {
14818 if(tempguy.family==eePROJECTILE)
14819 {
14820 tempguy.attributes[0] = 0;
14821 }
14822 }
14823
14824
1/2
✓ Branch 0 taken 202240 times.
✗ Branch 1 not taken.
202240 if(guyversion < 18) // January 2010
14825 {
14826 bool boss = (tempguy.family == eeAQUA || tempguy.family==eeDONGO || tempguy.family == eeMANHAN || tempguy.family == eeGHOMA || tempguy.family==eeDIG
14827 || tempguy.family == eeGLEEOK || tempguy.family==eePATRA || tempguy.family == eeGANON || tempguy.family==eeMOLD);
14828
14829 tempguy.hitsfx = (boss && tempguy.family != eeMOLD && tempguy.family != eeDONGO && tempguy.family != eeDIG) ? WAV_GASP : 0;
14830 tempguy.deadsfx = (boss && (tempguy.family != eeDIG || tempguy.attributes[9] == 0)) ? WAV_GASP : WAV_EDEAD;
14831
14832 if(tempguy.family == eeAQUA)
14833 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eRAQUAM].defense[j];
14834 else if(tempguy.family == eeMANHAN)
14835 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eMANHAN].defense[j];
14836 else if(tempguy.family==eePATRA)
14837 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eGLEEOK1].defense[j];
14838 else if(tempguy.family==eeGHOMA)
14839 {
14840 for(int32_t j=0; j<edefLAST; j++)
14841 tempguy.defense[j] = default_guys[eGOHMA1].defense[j];
14842
14843 tempguy.defense[edefARROW] = ((tempguy.attributes[0]==3) ? edCHINKL8 : (tempguy.attributes[0]==2) ? edCHINKL4 : 0);
14844
14845 if(tempguy.attributes[0]==3 && !tempguy.weapon) tempguy.weapon = ewFlame;
14846
14847 tempguy.attributes[0]--;
14848 }
14849 else if(tempguy.family == eeGLEEOK)
14850 {
14851 for(int32_t j=0; j<edefLAST; j++)
14852 tempguy.defense[j] = default_guys[eGLEEOK1].defense[j];
14853
14854 if(tempguy.attributes[2]==1 && !tempguy.weapon) tempguy.weapon = ewFlame;
14855 }
14856 else if(tempguy.family == eeARMOS)
14857 {
14858 tempguy.family=eeWALK;
14859 tempguy.hrate = 0;
14860 tempguy.attributes[9] = tempguy.attributes[0];
14861 tempguy.attributes[0] = tempguy.attributes[1] = tempguy.attributes[2] = tempguy.attributes[3] = tempguy.attributes[4] = tempguy.attributes[5] = tempguy.attributes[6] = tempguy.attributes[7] = 0;
14862 tempguy.attributes[0] = tempguy.attributes[1] = tempguy.attributes[2] = tempguy.attributes[3] = tempguy.attributes[4] = tempguy.attributes[5] = tempguy.attributes[6] = tempguy.attributes[7] = 0;
14863 tempguy.attributes[8] = e9tARMOS;
14864 }
14865 else if(tempguy.family == eeGHINI && !tempguy.attributes[0])
14866 {
14867 tempguy.family=eeWALK;
14868 tempguy.hrate = 0;
14869 tempguy.attributes[0] = tempguy.attributes[1] = tempguy.attributes[2] = tempguy.attributes[3] = tempguy.attributes[4] = tempguy.attributes[5] =
14870 tempguy.attributes[6] = tempguy.attributes[7] = tempguy.attributes[8] = tempguy.attributes[9] = 0;
14871 }
14872
14873 // Spawn animation flags
14874 if(tempguy.family == eeWALK && (tempguy.flags&guy_armos || tempguy.flags&guy_ghini))
14875 tempguy.flags |= guy_fade_flicker;
14876 else
14877 tempguy.flags &= (guy_flags)0x0F00000F; // Get rid of the unused flags!
14878 }
14879
14880
1/2
✓ Branch 0 taken 202240 times.
✗ Branch 1 not taken.
202240 if(guyversion < 20) // April 2010
14881 {
14882 if(tempguy.family == eeTRAP)
14883 {
14884 tempguy.attributes[1] = tempguy.attributes[9];
14885
14886 if(tempguy.attributes[9]>=1)
14887 {
14888 tempguy.attributes[0]++;
14889 }
14890
14891 tempguy.attributes[9] = 0;
14892 }
14893
14894 // Bomb Blast fix
14895 if(tempguy.weapon==ewBomb && tempguy.family!=eeROPE && (tempguy.family!=eeWALK || tempguy.attributes[1] != e2tBOMBCHU))
14896 tempguy.weapon = ewLitBomb;
14897 else if(tempguy.weapon==ewSBomb && tempguy.family!=eeROPE && (tempguy.family!=eeWALK || tempguy.attributes[1] != e2tBOMBCHU))
14898 tempguy.weapon = ewLitSBomb;
14899 }
14900
14901
1/2
✓ Branch 0 taken 202240 times.
✗ Branch 1 not taken.
202240 if(guyversion < 21) // September 2011
14902 {
14903 if(tempguy.family == eeKEESE || tempguy.family == eeKEESETRIB)
14904 {
14905 if(tempguy.family == eeKEESETRIB)
14906 {
14907 tempguy.family = eeKEESE;
14908 tempguy.attributes[1] = e2tKEESETRIB;
14909 tempguy.attributes[0] = 0;
14910 }
14911
14912 tempguy.rate = 2;
14913 tempguy.hrate = 8;
14914 tempguy.homing = 0;
14915 tempguy.step= (tempguy.family == eeKEESE && tempguy.attributes[0] ? 100:62);
14916 }
14917 else if(tempguy.family == eePEAHAT || tempguy.family==eePATRA)
14918 {
14919 if(tempguy.family == eePEAHAT)
14920 {
14921 tempguy.rate = 4;
14922 tempguy.step = 62;
14923 }
14924 else
14925 tempguy.step = 25;
14926
14927 tempguy.hrate = 8;
14928 tempguy.homing = 0;
14929 }
14930 else if(tempguy.family == eeDIG || tempguy.family == eeMANHAN)
14931 {
14932 if(tempguy.family == eeMANHAN)
14933 tempguy.step=50;
14934
14935 tempguy.hrate = 16;
14936 tempguy.homing = 0;
14937 }
14938 else if(tempguy.family == eeGLEEOK)
14939 {
14940 tempguy.rate = 2;
14941 tempguy.homing = 0;
14942 tempguy.hrate = 9;
14943 tempguy.step=89;
14944 }
14945 else if(tempguy.family == eeGHINI)
14946 {
14947 tempguy.rate = 4;
14948 tempguy.hrate = 12;
14949 tempguy.step=62;
14950 tempguy.homing = 0;
14951 }
14952
14953 // Bigdig random rate fix
14954 if(tempguy.family==eeDIG && tempguy.attributes[9]==1)
14955 {
14956 tempguy.rate = 2;
14957 }
14958 }
14959
14960
1/2
✓ Branch 0 taken 202240 times.
✗ Branch 1 not taken.
202240 if(guyversion < 24) // November 2012
14961 {
14962 if(tempguy.family==eeLANM)
14963 tempguy.attributes[2] = 1;
14964 else if(tempguy.family==eeMOLD)
14965 tempguy.attributes[1] = 0;
14966 }
14967
14968
2/2
✓ Branch 0 taken 97280 times.
✓ Branch 1 taken 104960 times.
202240 if(guyversion < 33) //Whistle defence did not exist before this version of 2.54. -Z
14969 {
14970
2/2
✓ Branch 0 taken 1430 times.
✓ Branch 1 taken 103530 times.
104960 if(tempguy.family!=eeDIG)
14971 {
14972 103530 tempguy.defense[edefWhistle] = edIGNORE; //Might need to be ignore, universally.
14973 103530 }
14974
14975 104960 }
14976 // does not seem to solve the issue!
14977
1/2
✓ Branch 0 taken 202240 times.
✗ Branch 1 not taken.
202240 if ( Header->zelda_version <= 0x210 )
14978 {
14979 al_trace("Detected version %d for dodongo patch.\n",Header->zelda_version);
14980 if ( tempguy.family == eeDONGO )
14981 {
14982 tempguy.deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
14983 }
14984 }
14985
14986
2/2
✓ Branch 0 taken 97280 times.
✓ Branch 1 taken 104960 times.
202240 if(guyversion >= 42)
14987 {
14988
2/2
✓ Branch 0 taken 94720 times.
✓ Branch 1 taken 2560 times.
97280 if(guyversion >= 47)
14989 {
14990
1/2
✓ Branch 0 taken 94720 times.
✗ Branch 1 not taken.
94720 if(!p_igetl(&(tempguy.moveflags),f))
14991 {
14992 return qe_invalid;
14993 }
14994 94720 }
14995 else
14996 {
14997 byte fl;
14998
1/2
✓ Branch 0 taken 2560 times.
✗ Branch 1 not taken.
2560 if(!p_getc(&fl,f))
14999 {
15000 return qe_invalid;
15001 }
15002 2560 tempguy.moveflags = (move_flags)fl;
15003 }
15004 97280 }
15005 else
15006 {
15007
7/8
✓ Branch 0 taken 3146 times.
✓ Branch 1 taken 82805 times.
✓ Branch 2 taken 2767 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 970 times.
✓ Branch 5 taken 655 times.
✓ Branch 6 taken 508 times.
✓ Branch 7 taken 14109 times.
104960 switch(tempguy.family)
15008 {
15009 //No gravity; floats over pits
15010 case eeTEK: case eePEAHAT: case eeROCK: case eeTRAP:
15011 case eePROJECTILE: case eeSPINTILE: case eeKEESE: case eeFIRE:
15012 //Special (bosses, etc)
15013 case eeFAIRY: case eeGUY: case eeNONE: case eeZORA:
15014 case eeAQUA: case eeDIG: case eeGHOMA: case eeGANON:
15015 case eePATRA: case eeGLEEOK: case eeMOLD: case eeMANHAN:
15016 82805 tempguy.moveflags = move_can_pitwalk;
15017 82805 break;
15018 //No gravity, but falls in pits
15019 case eeLEV:
15020 970 tempguy.moveflags = move_can_pitfall;
15021 970 break;
15022 //Bosses that respect pits
15023 case eeDONGO:
15024 655 tempguy.moveflags = move_obeys_grav;
15025 655 break;
15026 case eeLANM:
15027 508 tempguy.moveflags = move_none;
15028 508 break;
15029 //Gravity, floats over pits
15030 case eeWIZZ: case eeWALLM: case eeGHINI:
15031 2767 tempguy.moveflags = move_obeys_grav | move_can_pitwalk;
15032 2767 break;
15033 //Gravity and falls in pits
15034 case eeWALK:
15035
4/4
✓ Branch 0 taken 13399 times.
✓ Branch 1 taken 710 times.
✓ Branch 2 taken 538 times.
✓ Branch 3 taken 12861 times.
14109 if (tempguy.attributes[8]==e9tPOLSVOICE||tempguy.attributes[8]==e9tVIRE)
15036 1248 break;
15037 [[fallthrough]];
15038 case eeOTHER:
15039 case eeSCRIPT01: case eeSCRIPT02: case eeSCRIPT03: case eeSCRIPT04: case eeSCRIPT05:
15040 case eeSCRIPT06: case eeSCRIPT07: case eeSCRIPT08: case eeSCRIPT09: case eeSCRIPT10:
15041 case eeSCRIPT11: case eeSCRIPT12: case eeSCRIPT13: case eeSCRIPT14: case eeSCRIPT15:
15042 case eeSCRIPT16: case eeSCRIPT17: case eeSCRIPT18: case eeSCRIPT19: case eeSCRIPT20:
15043 case eeFFRIENDLY01: case eeFFRIENDLY02: case eeFFRIENDLY03: case eeFFRIENDLY04: case eeFFRIENDLY05:
15044 case eeFFRIENDLY06: case eeFFRIENDLY07: case eeFFRIENDLY08: case eeFFRIENDLY09: case eeFFRIENDLY10:
15045 16007 tempguy.moveflags = move_obeys_grav | move_can_pitfall;
15046 16007 }
15047 }
15048
2/2
✓ Branch 0 taken 97280 times.
✓ Branch 1 taken 104960 times.
202240 if(guyversion < 43)
15049 {
15050
2/2
✓ Branch 0 taken 85572 times.
✓ Branch 1 taken 19388 times.
104960 switch(tempguy.family)
15051 {
15052 //No gravity; floats over pits
15053 case eeTEK: case eePEAHAT: case eeROCK: case eeTRAP:
15054 case eePROJECTILE: case eeSPINTILE: case eeKEESE: case eeFIRE:
15055 //Special (bosses, etc)
15056 case eeFAIRY: case eeGUY: case eeNONE: case eeZORA:
15057 case eeAQUA: case eeDIG: case eeGHOMA: case eeGANON:
15058 case eePATRA: case eeGLEEOK: case eeMOLD: case eeMANHAN:
15059 case eeWIZZ: case eeWALLM: case eeGHINI:
15060 //Gravity, floats over pits
15061 85572 tempguy.moveflags |= move_can_waterwalk;
15062 85572 tempguy.moveflags |= move_can_pitwalk;
15063 85572 break;
15064 }
15065 104960 }
15066
2/2
✓ Branch 0 taken 97280 times.
✓ Branch 1 taken 104960 times.
202240 if (guyversion < 44)
15067 {
15068
2/2
✓ Branch 0 taken 104028 times.
✓ Branch 1 taken 932 times.
104960 if ( tempguy.family == eeGHOMA )
15069 {
15070 932 tempguy.flags |= guy_fade_instant;
15071 932 }
15072 104960 }
15073
2/2
✓ Branch 0 taken 97280 times.
✓ Branch 1 taken 104960 times.
202240 if (guyversion > 44)
15074 {
15075
1/2
✓ Branch 0 taken 97280 times.
✗ Branch 1 not taken.
97280 if(!p_getc(&(tempguy.spr_shadow),f))
15076 {
15077 return qe_invalid;
15078 }
15079
1/2
✓ Branch 0 taken 97280 times.
✗ Branch 1 not taken.
97280 if(!p_getc(&(tempguy.spr_death),f))
15080 {
15081 return qe_invalid;
15082 }
15083
1/2
✓ Branch 0 taken 97280 times.
✗ Branch 1 not taken.
97280 if(!p_getc(&(tempguy.spr_spawn),f))
15084 {
15085 return qe_invalid;
15086 }
15087 97280 }
15088 else
15089 {
15090
2/2
✓ Branch 0 taken 104553 times.
✓ Branch 1 taken 407 times.
104960 tempguy.spr_shadow = (tempguy.family==eeROCK && tempguy.attributes[9]==1) ? iwLargeShadow : iwShadow;
15091 104960 tempguy.spr_death = iwDeath;
15092 104960 tempguy.spr_spawn = iwSpawn;
15093 }
15094
15095
2/2
✓ Branch 0 taken 97280 times.
✓ Branch 1 taken 104960 times.
202240 if(guyversion < 46)
15096 {
15097
4/4
✓ Branch 0 taken 14109 times.
✓ Branch 1 taken 90851 times.
✓ Branch 2 taken 13399 times.
✓ Branch 3 taken 710 times.
104960 if(tempguy.family == eeWALK && tempguy.attributes[8] == e9tPOLSVOICE)
15098 {
15099 710 tempguy.moveflags |= move_can_waterwalk;
15100 710 }
15101 104960 }
15102
15103
2/2
✓ Branch 0 taken 94720 times.
✓ Branch 1 taken 107520 times.
202240 if (guyversion < 47)
15104 {
15105
4/4
✓ Branch 0 taken 1460 times.
✓ Branch 1 taken 106060 times.
✓ Branch 2 taken 876 times.
✓ Branch 3 taken 584 times.
107520 if (tempguy.family == eeDIG && tempguy.attributes[9]!=1)
15106 {
15107 584 tempguy.flags |= guy_ignore_kill_all;
15108 584 }
15109 107520 }
15110
15111
2/2
✓ Branch 0 taken 74240 times.
✓ Branch 1 taken 128000 times.
202240 if (guyversion < 49)
15112 {
15113
8/8
✓ Branch 0 taken 16638 times.
✓ Branch 1 taken 111362 times.
✓ Branch 2 taken 16157 times.
✓ Branch 3 taken 481 times.
✓ Branch 4 taken 15665 times.
✓ Branch 5 taken 492 times.
✓ Branch 6 taken 537 times.
✓ Branch 7 taken 15128 times.
128000 if (tempguy.family == eeWALK && (tempguy.attributes[6]==e7tPERMJINX || tempguy.attributes[6]==e7tTEMPJINX || tempguy.attributes[6]==e7tUNJINX)) //BUBBLE CHECK
15114 {
15115
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 722 times.
✓ Branch 2 taken 727 times.
✓ Branch 3 taken 61 times.
1510 switch (tempguy.attributes[7]) {
15116 case 0: //Sword
15117 722 tempguy.attributes[7] = e8tSWORD;
15118 722 break;
15119 case 1: //Item
15120 727 tempguy.attributes[7] = e8tITEM;
15121 727 break;
15122 case 2: //Both
15123 61 tempguy.attributes[7] = e8tSWORD|e8tITEM;
15124 61 break;
15125 default: //this can actually happen since Misc8 can be set to any number.
15126 tempguy.attributes[7] = 0;
15127 break;
15128 }
15129 1510 }
15130 128000 }
15131
15132 //these could possible be combined but rather be safe...
15133
2/2
✓ Branch 0 taken 74240 times.
✓ Branch 1 taken 128000 times.
202240 if (guyversion < 51) //reimport the firesfx, zoria ducked up.
15134 {
15135 128000 guy_update_firesfx(tempguy);
15136 128000 }
15137
2/2
✓ Branch 0 taken 128000 times.
✓ Branch 1 taken 74240 times.
202240 if (guyversion < 52)
15138 {
15139 128000 guy_update_weaponflags(tempguy);
15140 128000 }
15141 else
15142 {
15143
1/2
✓ Branch 0 taken 74240 times.
✗ Branch 1 not taken.
74240 if (!p_getc(&(tempguy.wunblockable), f))
15144 return qe_invalid;
15145
1/2
✓ Branch 0 taken 74240 times.
✗ Branch 1 not taken.
74240 if (!p_igetl(&(tempguy.wmoveflags), f))
15146 return qe_invalid;
15147
1/2
✓ Branch 0 taken 74240 times.
✗ Branch 1 not taken.
74240 if (!p_igetl(&(tempguy.weapoverrideFLAGS), f))
15148 return qe_invalid;
15149
1/2
✓ Branch 0 taken 74240 times.
✗ Branch 1 not taken.
74240 if (!p_igetl(&(tempguy.weap_tilew), f))
15150 return qe_invalid;
15151
1/2
✓ Branch 0 taken 74240 times.
✗ Branch 1 not taken.
74240 if (!p_igetl(&(tempguy.weap_tileh), f))
15152 return qe_invalid;
15153
1/2
✓ Branch 0 taken 74240 times.
✗ Branch 1 not taken.
74240 if (!p_igetl(&(tempguy.weap_hxsz), f))
15154 return qe_invalid;
15155
1/2
✓ Branch 0 taken 74240 times.
✗ Branch 1 not taken.
74240 if (!p_igetl(&(tempguy.weap_hysz), f))
15156 return qe_invalid;
15157
1/2
✓ Branch 0 taken 74240 times.
✗ Branch 1 not taken.
74240 if (!p_igetl(&(tempguy.weap_hzsz), f))
15158 return qe_invalid;
15159
1/2
✓ Branch 0 taken 74240 times.
✗ Branch 1 not taken.
74240 if (!p_igetl(&(tempguy.weap_hxofs), f))
15160 return qe_invalid;
15161
1/2
✓ Branch 0 taken 74240 times.
✗ Branch 1 not taken.
74240 if (!p_igetl(&(tempguy.weap_hyofs), f))
15162 return qe_invalid;
15163
1/2
✓ Branch 0 taken 74240 times.
✗ Branch 1 not taken.
74240 if (!p_igetl(&(tempguy.weap_xofs), f))
15164 return qe_invalid;
15165
1/2
✓ Branch 0 taken 74240 times.
✗ Branch 1 not taken.
74240 if (!p_igetl(&(tempguy.weap_yofs), f))
15166 return qe_invalid;
15167
1/2
✓ Branch 0 taken 74240 times.
✗ Branch 1 not taken.
74240 if (!p_igetl(&(tempguy.wstep), f))
15168 return qe_invalid;
15169
2/2
✓ Branch 0 taken 371200 times.
✓ Branch 1 taken 74240 times.
445440 for (int32_t q = 0; q < WPNSPR_MAX; ++q)
15170 {
15171
1/2
✓ Branch 0 taken 371200 times.
✗ Branch 1 not taken.
371200 if (!p_igetw(&(tempguy.burnsprs[q]), f))
15172 return qe_invalid;
15173
1/2
✓ Branch 0 taken 371200 times.
✗ Branch 1 not taken.
371200 if (!p_igetw(&(tempguy.light_rads[q]), f))
15174 return qe_invalid;
15175 371200 }
15176 }
15177
2/2
✓ Branch 0 taken 128000 times.
✓ Branch 1 taken 74240 times.
202240 if (guyversion < 53)
15178 {
15179 128000 guy_update_weaponspecialsfx(tempguy);
15180 128000 }
15181 else
15182 {
15183
1/2
✓ Branch 0 taken 74240 times.
✗ Branch 1 not taken.
74240 if (!p_getc(&(tempguy.specialsfx), f))
15184 return qe_invalid;
15185 }
15186
15187
1/2
✓ Branch 0 taken 202240 times.
✗ Branch 1 not taken.
202240 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
15188 {
15189 tempguy.script = 0;
15190 for(int q = 0; q < 8; ++q)
15191 tempguy.initD[q] = 0;
15192 }
15193 202240 guysbuf[i] = tempguy;
15194 202240 }
15195 395 }
15196
15197 395 return 0;
15198 477 }
15199
15200 void update_guy_1(guydata *tempguy) // November 2009
15201 {
15202 bool doesntcount = false;
15203 tempguy->flags &= ~guy_weak_arrow; // Formerly 'weak to arrow' which wasn't implemented
15204
15205 switch(tempguy->family)
15206 {
15207 case 1: //eeWALK
15208 switch(tempguy->attributes[9])
15209 {
15210 case 0: //Stalfos
15211 if(tempguy->attributes[0]==1) // Fires four projectiles at once
15212 tempguy->attributes[0]=4;
15213
15214 break;
15215
15216 case 1: //Darknut
15217 goto darknuts;
15218 break;
15219 }
15220
15221 tempguy->attributes[9] = 0;
15222 break;
15223
15224 case 2: //eeSHOOT
15225 tempguy->family = eeWALK;
15226
15227 switch(tempguy->attributes[9])
15228 {
15229 case 0: //Octorok
15230 if(tempguy->attributes[0]==1||tempguy->attributes[0]==2)
15231 {
15232 tempguy->attributes[0]=e1tFIREOCTO;
15233 tempguy->attributes[1]=e2tFIREOCTO;
15234 }
15235 else tempguy->attributes[0] = 0;
15236
15237 tempguy->attributes[5]=tempguy->attributes[3];
15238 tempguy->attributes[3]=tempguy->attributes[2];
15239 tempguy->attributes[2]=0;
15240 break;
15241
15242 case 1: // Moblin
15243 tempguy->attributes[0] = 0;
15244 break;
15245
15246 case 2: //Lynel
15247 tempguy->attributes[5]=tempguy->attributes[0]+1;
15248 tempguy->attributes[0]=0;
15249 break;
15250
15251 case 3: //Stalfos 2
15252 if(tempguy->attributes[0]==1) // Fires four projectiles at once
15253 tempguy->attributes[0]=e1t4SHOTS;
15254 else tempguy->attributes[0] = 0;
15255
15256 break;
15257
15258 case 4: //Darknut 5
15259 darknuts:
15260 tempguy->defense[edefFIRE] = edIGNORE;
15261 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15262 tempguy->defense[edefHOOKSHOT] = 0;
15263 tempguy->defense[edefARROW] = tempguy->defense[edefBYRNA] = tempguy->defense[edefREFROCK] =
15264 tempguy->defense[edefMAGIC] = tempguy->defense[edefSTOMP] = edCHINK;
15265
15266 if(tempguy->attributes[0]==1)
15267 tempguy->attributes[0]=2;
15268 else if(tempguy->attributes[0]==2)
15269 {
15270 tempguy->attributes[3]=tempguy->attributes[2];
15271 tempguy->attributes[2]=tempguy->attributes[1];
15272 tempguy->attributes[1]=e2tSPLIT;
15273 tempguy->attributes[0] = 0;
15274 }
15275 else tempguy->attributes[0] = 0;
15276
15277 tempguy->flags |= guy_shield_front;
15278
15279 if(!get_bit(deprecated_rules,qr_BRKBLSHLDS_DEP))
15280 tempguy->flags &= ~guy_bkshield;
15281 else
15282 tempguy->flags |= guy_bkshield;
15283
15284 break;
15285 }
15286
15287 tempguy->attributes[9] = 0;
15288 break;
15289
15290 /*
15291 case 9: //eeARMOS
15292 tempguy->family = eeWALK;
15293 break;
15294 */
15295 case 11: //eeGEL
15296 case 33: //eeGELTRIB
15297 if(tempguy->family==33)
15298 {
15299 tempguy->attributes[3] = 1;
15300
15301 if(get_bit(deprecated_rules, qr_OLDTRIBBLES_DEP)) //Old Tribbles
15302 tempguy->attributes[2] = tempguy->attributes[1];
15303
15304 tempguy->attributes[1] = e2tTRIBBLE;
15305 }
15306 else
15307 {
15308 tempguy->attributes[3] = 0;
15309 tempguy->attributes[2] = 0;
15310 tempguy->attributes[1] = 0;
15311 }
15312
15313 tempguy->family = eeWALK;
15314
15315 if(tempguy->attributes[0])
15316 {
15317 tempguy->attributes[0]=1;
15318 tempguy->weapon = ewFireTrail;
15319 }
15320
15321 break;
15322
15323 case 34: //eeZOLTRIB
15324 case 12: //eeZOL
15325 tempguy->attributes[3]=tempguy->attributes[2];
15326 tempguy->attributes[2]=tempguy->attributes[1];
15327 tempguy->family = eeWALK;
15328 tempguy->attributes[1]=e2tSPLITHIT;
15329
15330 if(tempguy->attributes[0])
15331 {
15332 tempguy->attributes[0]=1;
15333 tempguy->weapon = ewFireTrail;
15334 }
15335
15336 break;
15337
15338 case 13: //eeROPE
15339 tempguy->family = eeWALK;
15340 tempguy->attributes[8] = e9tROPE;
15341
15342 if(tempguy->attributes[0])
15343 {
15344 tempguy->attributes[3] = tempguy->attributes[2];
15345 tempguy->attributes[2] = tempguy->attributes[1];
15346 tempguy->attributes[1] = e2tBOMBCHU;
15347 }
15348
15349 tempguy->attributes[0] = 0;
15350 break;
15351
15352 case 14: //eeGORIYA
15353 tempguy->family = eeWALK;
15354
15355 if(tempguy->attributes[0]!=2) tempguy->attributes[0] = 0;
15356
15357 break;
15358
15359 case 17: //eeBUBBLE
15360 tempguy->family = eeWALK;
15361 tempguy->attributes[7] = tempguy->attributes[1];
15362 tempguy->attributes[6] = tempguy->attributes[0] + 1;
15363 tempguy->attributes[0] = tempguy->attributes[1] = 0;
15364
15365 //fallthrogh
15366 case eeTRAP:
15367 case eeROCK:
15368 doesntcount = true;
15369 break;
15370
15371 case 35: //eeVIRETRIB
15372 case 18: //eeVIRE
15373 tempguy->family = eeWALK;
15374 tempguy->attributes[3]=tempguy->attributes[2];
15375 tempguy->attributes[2]=tempguy->attributes[1];
15376 tempguy->attributes[1]=e2tSPLITHIT;
15377 tempguy->attributes[8]=e9tVIRE;
15378 break;
15379
15380 case 19: //eeLIKE
15381 tempguy->family = eeWALK;
15382 tempguy->attributes[6] = e7tEATITEMS;
15383 tempguy->attributes[7]=95;
15384 break;
15385
15386 case 20: //eePOLSV
15387 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15388 tempguy->defense[edefBOMB] = tempguy->defense[edefSBOMB] = tempguy->defense[edefFIRE] = edIGNORE;
15389 tempguy->defense[edefMAGIC] = tempguy->defense[edefBYRNA] = edCHINK;
15390 tempguy->defense[edefARROW] = ed1HKO;
15391 tempguy->defense[edefHOOKSHOT] = edSTUNONLY;
15392 tempguy->family = eeWALK;
15393 tempguy->attributes[8] = e9tPOLSVOICE;
15394 tempguy->rate = 4;
15395 tempguy->homing = 32;
15396 tempguy->hrate = 10;
15397 tempguy->grumble = 0;
15398 break;
15399
15400 case eeWIZZ:
15401 if(tempguy->attributes[3])
15402 {
15403 for(int32_t i=0; i < edefLAST; i++)
15404 tempguy->defense[i] = (i != edefREFBEAM && i != edefREFMAGIC && i != edefQUAKE) ? edIGNORE : 0;
15405 }
15406 else
15407 {
15408 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15409 tempguy->defense[edefMAGIC] = edCHINK;
15410 tempguy->defense[edefHOOKSHOT] = edSTUNONLY;
15411 tempguy->defense[edefARROW] = tempguy->defense[edefFIRE] =
15412 tempguy->defense[edefWAND] = tempguy->defense[edefBYRNA] = edIGNORE;
15413 }
15414
15415 break;
15416
15417 case eePEAHAT:
15418 tempguy->flags &= ~(guy_superman|guy_sbombonly);
15419
15420 if(!(tempguy->flags & guy_bhit))
15421 tempguy->defense[edefBRANG] = edSTUNONLY;
15422
15423 break;
15424
15425 case eeLEV:
15426 tempguy->defense[edefSTOMP] = edCHINK;
15427 break;
15428 }
15429
15430 // Old flags
15431 if(tempguy->flags & guy_superman)
15432 {
15433 for(int32_t i = 0; i < edefLAST; i++)
15434 if(!(i==edefSBOMB && (tempguy->flags & guy_sbombonly)))
15435 tempguy->defense[i] = (i==edefBRANG && tempguy->defense[i] != edIGNORE
15436 && tempguy->family != eeROCK && tempguy->family != eeTRAP
15437 && tempguy->family != eePROJECTILE) ? edSTUNORIGNORE : edIGNORE;
15438 }
15439
15440 tempguy->flags &= ~(guy_superman|guy_sbombonly);
15441
15442 if(doesntcount)
15443 tempguy->flags |= (guy_doesnt_count);
15444 }
15445
15446 1186472 int32_t readmapscreen_old(PACKFILE *f, zquestheader *Header, mapscr *temp_mapscr, word version, int scrind)
15447 {
15448 byte tempbyte, padding;
15449 int32_t extras, secretcombos;
15450
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186472 times.
1186472 if(!p_getc(&(temp_mapscr->valid),f))
15451 {
15452 return qe_invalid;
15453 }
15454
15455
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186472 times.
1186472 if(!p_getc(&(temp_mapscr->guy),f))
15456 return qe_invalid;
15457 1186472 temp_mapscr->guytile = -1; //signal to use default guy values
15458
2/2
✓ Branch 0 taken 1185873 times.
✓ Branch 1 taken 599 times.
1186472 SETFLAG(temp_mapscr->roomflags,RFL_ALWAYS_GUY,temp_mapscr->guy==gFAIRY);
15459
4/4
✓ Branch 0 taken 599 times.
✓ Branch 1 taken 1185873 times.
✓ Branch 2 taken 60 times.
✓ Branch 3 taken 539 times.
1186472 SETFLAG(temp_mapscr->roomflags,RFL_GUYFIRES,temp_mapscr->guy!=gFAIRY || !get_qr(qr_NOFAIRYGUYFIRES));
15460
15461
5/6
✓ Branch 0 taken 1164296 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1161576 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1186472 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<146)))
15462 {
15463
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22176 times.
22176 if(!p_getc(&tempbyte,f))
15464 {
15465 return qe_invalid;
15466 }
15467
15468 22176 temp_mapscr->str=tempbyte;
15469 22176 }
15470 else
15471 {
15472
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1164296 times.
1164296 if(!p_igetw(&(temp_mapscr->str),f))
15473 {
15474 return qe_invalid;
15475 }
15476 }
15477
15478
1/2
✓ Branch 0 taken 1186472 times.
✗ Branch 1 not taken.
1186472 if(!p_getc(&(temp_mapscr->room),f))
15479 {
15480 return qe_invalid;
15481 }
15482
15483
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186472 times.
1186472 if(!p_getc(&(temp_mapscr->item),f))
15484 {
15485 return qe_invalid;
15486 }
15487
15488
3/6
✓ Branch 0 taken 657968 times.
✓ Branch 1 taken 528504 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 657968 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1186472 if(Header->zelda_version < 0x211 || (Header->zelda_version == 0x211 && Header->build < 14))
15489 {
15490 528504 temp_mapscr->hasitem = (temp_mapscr->item != 0) ? 1 : 0;
15491 528504 }
15492 else
15493 {
15494
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 657968 times.
657968 if(!p_getc(&(temp_mapscr->hasitem),f))
15495 return qe_invalid;
15496 }
15497
15498
3/4
✓ Branch 0 taken 1164296 times.
✓ Branch 1 taken 22176 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1189192 if((Header->zelda_version < 0x192)||
15499
2/2
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1161576 times.
1164296 ((Header->zelda_version == 0x192)&&(Header->build<154)))
15500 {
15501
1/2
✓ Branch 0 taken 22176 times.
✗ Branch 1 not taken.
22176 if(!p_getc(&tempbyte,f))
15502 {
15503 return qe_invalid;
15504 }
15505 22176 }
15506
15507
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186472 times.
1186472 if(!p_getc(&(temp_mapscr->tilewarptype[0]),f))
15508 {
15509 return qe_invalid;
15510 }
15511
15512
2/2
✓ Branch 0 taken 1161576 times.
✓ Branch 1 taken 24896 times.
1186472 if(Header->zelda_version < 0x193)
15513 {
15514
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24896 times.
24896 if(!p_getc(&tempbyte,f))
15515 {
15516 return qe_invalid;
15517 }
15518 24896 }
15519
15520
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 657968 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1186472 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15521 {
15522
2/2
✓ Branch 0 taken 1973904 times.
✓ Branch 1 taken 657968 times.
2631872 for(int32_t i=1; i<4; i++)
15523 {
15524
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1973904 times.
1973904 if(!p_getc(&(temp_mapscr->tilewarptype[i]),f))
15525 {
15526 return qe_invalid;
15527 }
15528 1973904 }
15529 657968 }
15530 else
15531 {
15532 528504 temp_mapscr->tilewarptype[1]=0;
15533 528504 temp_mapscr->tilewarptype[2]=0;
15534 528504 temp_mapscr->tilewarptype[3]=0;
15535 }
15536
15537
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1161576 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1186472 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
15538 {
15539
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1164296 times.
1164296 if(!p_igetw(&(temp_mapscr->door_combo_set),f))
15540 {
15541 return qe_invalid;
15542 }
15543 1164296 }
15544
15545
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186472 times.
1186472 if(!p_getc(&(temp_mapscr->warpreturnx[0]),f))
15546 {
15547 return qe_invalid;
15548 }
15549
15550 1186472 temp_mapscr->warpreturnx[1]=0;
15551 1186472 temp_mapscr->warpreturnx[2]=0;
15552 1186472 temp_mapscr->warpreturnx[3]=0;
15553
15554
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 657968 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1186472 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15555 {
15556
2/2
✓ Branch 0 taken 1973904 times.
✓ Branch 1 taken 657968 times.
2631872 for(int32_t i=1; i<4; i++)
15557 {
15558
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1973904 times.
1973904 if(!p_getc(&(temp_mapscr->warpreturnx[i]),f))
15559 {
15560 return qe_invalid;
15561 }
15562 1973904 }
15563 657968 }
15564
15565
1/2
✓ Branch 0 taken 1186472 times.
✗ Branch 1 not taken.
1186472 if(!p_getc(&(temp_mapscr->warpreturny[0]),f))
15566 {
15567 return qe_invalid;
15568 }
15569
15570 1186472 temp_mapscr->warpreturny[1]=0;
15571 1186472 temp_mapscr->warpreturny[2]=0;
15572 1186472 temp_mapscr->warpreturny[3]=0;
15573
15574
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 657968 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1186472 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15575 {
15576
2/2
✓ Branch 0 taken 1973904 times.
✓ Branch 1 taken 657968 times.
2631872 for(int32_t i=1; i<4; i++)
15577 {
15578
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1973904 times.
1973904 if(!p_getc(&(temp_mapscr->warpreturny[i]),f))
15579 {
15580 return qe_invalid;
15581 }
15582 1973904 }
15583
15584
1/2
✓ Branch 0 taken 657968 times.
✗ Branch 1 not taken.
657968 if(version>=18)
15585 {
15586
1/2
✓ Branch 0 taken 657968 times.
✗ Branch 1 not taken.
657968 if(!p_igetw(&temp_mapscr->warpreturnc,f))
15587 {
15588 return qe_invalid;
15589 }
15590 657968 }
15591 else
15592 {
15593 byte temp;
15594
15595 if(!p_getc(&temp,f))
15596 {
15597 return qe_invalid;
15598 }
15599
15600 temp_mapscr->warpreturnc=temp<<8|temp;
15601 }
15602 657968 }
15603
15604
1/2
✓ Branch 0 taken 1186472 times.
✗ Branch 1 not taken.
1186472 if(!p_getc(&(temp_mapscr->stairx),f))
15605
15606 {
15607 return qe_invalid;
15608 }
15609
15610
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186472 times.
1186472 if(!p_getc(&(temp_mapscr->stairy),f))
15611 {
15612 return qe_invalid;
15613 }
15614
15615
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186472 times.
1186472 if(!p_getc(&(temp_mapscr->itemx),f))
15616 {
15617 return qe_invalid;
15618 }
15619
15620
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186472 times.
1186472 if(!p_getc(&(temp_mapscr->itemy),f))
15621 {
15622 return qe_invalid;
15623 }
15624
15625
2/2
✓ Branch 0 taken 657968 times.
✓ Branch 1 taken 528504 times.
1186472 if(version > 15) // February 2009
15626 {
15627
1/2
✓ Branch 0 taken 657968 times.
✗ Branch 1 not taken.
657968 if(!p_igetw(&(temp_mapscr->color),f))
15628 {
15629 return qe_invalid;
15630 }
15631 657968 }
15632 else
15633 {
15634
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 528504 times.
528504 if(!p_getc(& tempbyte,f))
15635 {
15636 return qe_invalid;
15637 }
15638
15639 528504 temp_mapscr->color = (word) tempbyte;
15640 }
15641
15642
1/2
✓ Branch 0 taken 1186472 times.
✗ Branch 1 not taken.
1186472 if(!p_getc(&(temp_mapscr->flags11),f))
15643 {
15644 return qe_invalid;
15645 }
15646
15647
2/2
✓ Branch 0 taken 4745888 times.
✓ Branch 1 taken 1186472 times.
5932360 for(int32_t k=0; k<4; k++)
15648 {
15649
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4745888 times.
4745888 if(!p_getc(&(temp_mapscr->door[k]),f))
15650 {
15651 return qe_invalid;
15652
15653 }
15654 4745888 }
15655
15656
2/2
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 657968 times.
1186472 if(version <= 11)
15657 {
15658
1/2
✓ Branch 0 taken 528504 times.
✗ Branch 1 not taken.
528504 if(!p_getc(&(tempbyte),f))
15659 {
15660 return qe_invalid;
15661 }
15662
15663 528504 temp_mapscr->tilewarpdmap[0]=(word)tempbyte;
15664
15665
2/6
✓ Branch 0 taken 528504 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
528504 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15666 {
15667 for(int32_t i=1; i<4; i++)
15668 {
15669 if(!p_getc(&(tempbyte),f))
15670 {
15671 return qe_invalid;
15672 }
15673
15674 temp_mapscr->tilewarpdmap[i]=(word)tempbyte;
15675 }
15676 }
15677 else
15678 {
15679 528504 temp_mapscr->tilewarpdmap[1]=0;
15680 528504 temp_mapscr->tilewarpdmap[2]=0;
15681 528504 temp_mapscr->tilewarpdmap[3]=0;
15682 }
15683 528504 }
15684 else
15685 {
15686
2/2
✓ Branch 0 taken 2631872 times.
✓ Branch 1 taken 657968 times.
3289840 for(int32_t i=0; i<4; i++)
15687 {
15688
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2631872 times.
2631872 if(!p_igetw(&(temp_mapscr->tilewarpdmap[i]),f))
15689 {
15690 return qe_invalid;
15691 }
15692 2631872 }
15693 }
15694
15695
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186472 times.
1186472 if(!p_getc(&(temp_mapscr->tilewarpscr[0]),f))
15696 {
15697 return qe_invalid;
15698 }
15699
15700
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 657968 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1186472 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15701 {
15702
2/2
✓ Branch 0 taken 1973904 times.
✓ Branch 1 taken 657968 times.
2631872 for(int32_t i=1; i<4; i++)
15703 {
15704
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1973904 times.
1973904 if(!p_getc(&(temp_mapscr->tilewarpscr[i]),f))
15705 {
15706 return qe_invalid;
15707 }
15708 1973904 }
15709 657968 }
15710 else
15711 {
15712 528504 temp_mapscr->tilewarpscr[1]=0;
15713 528504 temp_mapscr->tilewarpscr[2]=0;
15714 528504 temp_mapscr->tilewarpscr[3]=0;
15715 }
15716
15717
2/2
✓ Branch 0 taken 657968 times.
✓ Branch 1 taken 528504 times.
1186472 if(version >= 15)
15718 {
15719
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 657968 times.
657968 if(!p_getc(&(temp_mapscr->tilewarpoverlayflags),f))
15720 {
15721 return qe_invalid;
15722 }
15723 657968 }
15724 else
15725 {
15726 528504 temp_mapscr->tilewarpoverlayflags=0;
15727 }
15728
15729
1/2
✓ Branch 0 taken 1186472 times.
✗ Branch 1 not taken.
1186472 if(!p_getc(&(temp_mapscr->exitdir),f))
15730 {
15731 return qe_invalid;
15732 }
15733
15734
2/2
✓ Branch 0 taken 1161576 times.
✓ Branch 1 taken 24896 times.
1186472 if(Header->zelda_version < 0x193)
15735 {
15736
1/2
✓ Branch 0 taken 24896 times.
✗ Branch 1 not taken.
24896 if(!p_getc(&tempbyte,f))
15737 {
15738 return qe_invalid;
15739 }
15740
15741 24896 }
15742
15743
4/6
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1183752 times.
✓ Branch 2 taken 2720 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1186472 if((Header->zelda_version == 0x192)&&(Header->build>145)&&(Header->build<154))
15744 {
15745 if(!p_getc(&padding,f))
15746 {
15747 return qe_invalid;
15748 }
15749 }
15750
15751
2/2
✓ Branch 0 taken 11864720 times.
✓ Branch 1 taken 1186472 times.
13051192 for(int32_t k=0; k<10; k++)
15752 {
15753
5/6
✓ Branch 0 taken 11642960 times.
✓ Branch 1 taken 221760 times.
✓ Branch 2 taken 27200 times.
✓ Branch 3 taken 11615760 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 27200 times.
11864720 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<10)))
15754 {
15755
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 221760 times.
221760 if(!p_getc(&tempbyte,f))
15756 {
15757 return qe_invalid;
15758 }
15759
15760 221760 temp_mapscr->enemy[k]=tempbyte;
15761 221760 }
15762 else
15763 {
15764
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11642960 times.
11642960 if(!p_igetw(&(temp_mapscr->enemy[k]),f))
15765 {
15766 return qe_invalid;
15767 }
15768 }
15769
15770
5/6
✓ Branch 0 taken 11642960 times.
✓ Branch 1 taken 221760 times.
✓ Branch 2 taken 27200 times.
✓ Branch 3 taken 11615760 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 27200 times.
11864720 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<108)))
15771 {
15772 //using enumerations here is dangerous
15773 //very easy to break old quests -DD
15774
2/2
✓ Branch 0 taken 1342 times.
✓ Branch 1 taken 220418 times.
221760 if(temp_mapscr->enemy[k]>=57) //old eGOHMA1
15775 {
15776 1342 temp_mapscr->enemy[k]+=5;
15777 1342 }
15778
2/2
✓ Branch 0 taken 220324 times.
✓ Branch 1 taken 94 times.
220418 else if(temp_mapscr->enemy[k]>=52) //old eGLEEOK2
15779 {
15780 94 temp_mapscr->enemy[k]+=1;
15781 94 }
15782 221760 }
15783
15784
2/2
✓ Branch 0 taken 6579680 times.
✓ Branch 1 taken 5285040 times.
11864720 if(version < 9)
15785 {
15786
2/2
✓ Branch 0 taken 5009135 times.
✓ Branch 1 taken 275905 times.
5285040 if(temp_mapscr->enemy[k]>0)
15787 {
15788 275905 temp_mapscr->enemy[k]+=10;
15789 275905 }
15790 5285040 }
15791 //don't read in any invalid data
15792
2/2
✓ Branch 0 taken 11864270 times.
✓ Branch 1 taken 450 times.
11864720 if ( ((unsigned)temp_mapscr->enemy[k]) > MAXGUYS )
15793 {
15794 450 al_trace("Tried to read an invalid enemy ID (%d) for enemy[%d]. This has been cleared to 0.\n", temp_mapscr->enemy[k], k);
15795 450 temp_mapscr->enemy[k] = 0;
15796 450 }
15797 11864720 }
15798
15799
1/2
✓ Branch 0 taken 1186472 times.
✗ Branch 1 not taken.
1186472 if(!p_getc(&(temp_mapscr->pattern),f))
15800 {
15801 return qe_invalid;
15802 }
15803
15804
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186472 times.
1186472 if(!p_getc(&(temp_mapscr->sidewarptype[0]),f))
15805 {
15806 return qe_invalid;
15807 }
15808
15809
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 657968 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1186472 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15810 {
15811
2/2
✓ Branch 0 taken 1973904 times.
✓ Branch 1 taken 657968 times.
2631872 for(int32_t i=1; i<4; i++)
15812 {
15813
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1973904 times.
1973904 if(!p_getc(&(temp_mapscr->sidewarptype[i]),f))
15814 {
15815 return qe_invalid;
15816 }
15817 1973904 }
15818 657968 }
15819 else
15820 {
15821 528504 temp_mapscr->sidewarptype[1]=0;
15822 528504 temp_mapscr->sidewarptype[2]=0;
15823 528504 temp_mapscr->sidewarptype[3]=0;
15824 }
15825
15826
2/2
✓ Branch 0 taken 657968 times.
✓ Branch 1 taken 528504 times.
1186472 if(version >= 15)
15827 {
15828
1/2
✓ Branch 0 taken 657968 times.
✗ Branch 1 not taken.
657968 if(!p_getc(&(temp_mapscr->sidewarpoverlayflags),f))
15829 {
15830 return qe_invalid;
15831 }
15832 657968 }
15833 else
15834 {
15835 528504 temp_mapscr->sidewarpoverlayflags=0;
15836 }
15837
15838
1/2
✓ Branch 0 taken 1186472 times.
✗ Branch 1 not taken.
1186472 if(!p_getc(&(temp_mapscr->warparrivalx),f))
15839 {
15840 return qe_invalid;
15841 }
15842
15843
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186472 times.
1186472 if(!p_getc(&(temp_mapscr->warparrivaly),f))
15844 {
15845 return qe_invalid;
15846 }
15847
15848
2/2
✓ Branch 0 taken 4745888 times.
✓ Branch 1 taken 1186472 times.
5932360 for(int32_t k=0; k<4; k++)
15849 {
15850
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4745888 times.
4745888 if(!p_getc(&(temp_mapscr->path[k]),f))
15851 {
15852 return qe_invalid;
15853 }
15854 4745888 }
15855
15856
1/2
✓ Branch 0 taken 1186472 times.
✗ Branch 1 not taken.
1186472 if(!p_getc(&(temp_mapscr->sidewarpscr[0]),f))
15857 {
15858 return qe_invalid;
15859 }
15860
15861
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 657968 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1186472 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15862 {
15863
2/2
✓ Branch 0 taken 657968 times.
✓ Branch 1 taken 1973904 times.
2631872 for(int32_t i=1; i<4; i++)
15864 {
15865
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1973904 times.
1973904 if(!p_getc(&(temp_mapscr->sidewarpscr[i]),f))
15866 {
15867 return qe_invalid;
15868 }
15869 1973904 }
15870 657968 }
15871 else
15872 {
15873 528504 temp_mapscr->sidewarpscr[1]=0;
15874 528504 temp_mapscr->sidewarpscr[2]=0;
15875 528504 temp_mapscr->sidewarpscr[3]=0;
15876 }
15877
15878
2/2
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 657968 times.
1186472 if(version <= 11)
15879 {
15880
1/2
✓ Branch 0 taken 528504 times.
✗ Branch 1 not taken.
528504 if(!p_getc(&(tempbyte),f))
15881 {
15882 return qe_invalid;
15883 }
15884
15885 528504 temp_mapscr->sidewarpdmap[0]=(word)tempbyte;
15886
15887
2/6
✓ Branch 0 taken 528504 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
528504 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15888 {
15889 for(int32_t i=1; i<4; i++)
15890 {
15891 if(!p_getc(&(tempbyte),f))
15892 {
15893 return qe_invalid;
15894 }
15895
15896 temp_mapscr->sidewarpdmap[i]=(word)tempbyte;
15897 }
15898 }
15899 else
15900 {
15901 528504 temp_mapscr->sidewarpdmap[1]=0;
15902 528504 temp_mapscr->sidewarpdmap[2]=0;
15903 528504 temp_mapscr->sidewarpdmap[3]=0;
15904 }
15905 528504 }
15906 else
15907 {
15908
2/2
✓ Branch 0 taken 2631872 times.
✓ Branch 1 taken 657968 times.
3289840 for(int32_t i=0; i<4; i++)
15909 {
15910
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2631872 times.
2631872 if(!p_igetw(&(temp_mapscr->sidewarpdmap[i]),f))
15911 {
15912 return qe_invalid;
15913 }
15914 2631872 }
15915 }
15916
15917
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 657968 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1186472 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15918 {
15919
1/2
✓ Branch 0 taken 657968 times.
✗ Branch 1 not taken.
657968 if(!p_getc(&(temp_mapscr->sidewarpindex),f))
15920 {
15921 return qe_invalid;
15922 }
15923 657968 }
15924 528504 else temp_mapscr->sidewarpindex = 0;
15925
15926
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186472 times.
1186472 if(!p_igetw(&(temp_mapscr->undercombo),f))
15927 {
15928 return qe_invalid;
15929 }
15930
15931
2/2
✓ Branch 0 taken 1161576 times.
✓ Branch 1 taken 24896 times.
1186472 if(Header->zelda_version < 0x193)
15932 {
15933
1/2
✓ Branch 0 taken 24896 times.
✗ Branch 1 not taken.
24896 if (!p_getc(&old_combo_pages[scrind], f))
15934 {
15935 return qe_invalid;
15936 }
15937 24896 }
15938
15939
1/2
✓ Branch 0 taken 1186472 times.
✗ Branch 1 not taken.
1186472 if(!p_getc(&(temp_mapscr->undercset),f)) //recalculated for older quests
15940 {
15941 return qe_invalid;
15942 }
15943
15944
1/2
✓ Branch 0 taken 1186472 times.
✗ Branch 1 not taken.
1186472 if(!p_igetw(&(temp_mapscr->catchall),f))
15945 {
15946 return qe_invalid;
15947 }
15948
15949
1/2
✓ Branch 0 taken 1186472 times.
✗ Branch 1 not taken.
1186472 if(!p_getc(&(temp_mapscr->flags),f))
15950 {
15951 return qe_invalid;
15952 }
15953
15954
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186472 times.
1186472 if(!p_getc(&(temp_mapscr->flags2),f))
15955 {
15956 return qe_invalid;
15957 }
15958
15959
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186472 times.
1186472 if(!p_getc(&(temp_mapscr->flags3),f))
15960 {
15961 return qe_invalid;
15962 }
15963
15964
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 657968 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1186472 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>1)))
15965 //if (version>2)
15966 {
15967
1/2
✓ Branch 0 taken 657968 times.
✗ Branch 1 not taken.
657968 if(!p_getc(&(temp_mapscr->flags4),f))
15968 {
15969 return qe_invalid;
15970 }
15971 657968 }
15972
15973
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 657968 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1186472 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15974 {
15975
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 657968 times.
657968 if(!p_getc(&(temp_mapscr->flags5),f))
15976 {
15977 return qe_invalid;
15978 }
15979
15980
1/2
✓ Branch 0 taken 657968 times.
✗ Branch 1 not taken.
657968 if(!p_igetw(&(temp_mapscr->noreset),f))
15981 {
15982 return qe_invalid;
15983 }
15984
15985
1/2
✓ Branch 0 taken 657968 times.
✗ Branch 1 not taken.
657968 if(!p_igetw(&(temp_mapscr->nocarry),f))
15986 {
15987 return qe_invalid;
15988 }
15989
15990
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 657968 times.
657968 if(temp_mapscr->flags5&32)
15991 {
15992 temp_mapscr->flags5 &= ~32;
15993 temp_mapscr->noreset |= 48;
15994 }
15995
15996
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 657968 times.
657968 if(version<8)
15997 {
15998 if(temp_mapscr->noreset&1)
15999 {
16000 temp_mapscr->noreset|=8192;
16001 }
16002
16003 if(temp_mapscr->nocarry&1)
16004 {
16005 temp_mapscr->nocarry|=8192;
16006 temp_mapscr->nocarry&=~1;
16007 }
16008 }
16009 657968 }
16010 else
16011 {
16012 528504 temp_mapscr->flags5 = 0;
16013 528504 temp_mapscr->noreset = 0;
16014 528504 temp_mapscr->nocarry = 0;
16015 }
16016
16017
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 657968 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1186472 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>9)))
16018 {
16019
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 657968 times.
657968 if(!p_getc(&(temp_mapscr->flags6),f))
16020 {
16021 return qe_invalid;
16022 }
16023 657968 }
16024
16025
2/2
✓ Branch 0 taken 657968 times.
✓ Branch 1 taken 528504 times.
1186472 if(version>5)
16026 {
16027
1/2
✓ Branch 0 taken 657968 times.
✗ Branch 1 not taken.
657968 if(!p_getc(&(temp_mapscr->flags7),f))
16028 {
16029 return qe_invalid;
16030 }
16031
16032
1/2
✓ Branch 0 taken 657968 times.
✗ Branch 1 not taken.
657968 if(!p_getc(&(temp_mapscr->flags8),f))
16033 {
16034 return qe_invalid;
16035 }
16036
16037
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 657968 times.
657968 if(!p_getc(&(temp_mapscr->flags9),f))
16038 {
16039 return qe_invalid;
16040 }
16041
16042
1/2
✓ Branch 0 taken 657968 times.
✗ Branch 1 not taken.
657968 if(!p_getc(&(temp_mapscr->flags10),f))
16043 {
16044 return qe_invalid;
16045 }
16046
16047
1/2
✓ Branch 0 taken 657968 times.
✗ Branch 1 not taken.
657968 if(!p_getc(&(temp_mapscr->csensitive),f))
16048 {
16049 return qe_invalid;
16050 }
16051 657968 }
16052 else
16053 {
16054 528504 temp_mapscr->csensitive=1;
16055 }
16056
16057
2/2
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 657968 times.
1186472 if(version<14) // August 2007: screen SFX added
16058 {
16059
2/2
✓ Branch 0 taken 527510 times.
✓ Branch 1 taken 994 times.
528504 if(temp_mapscr->flags&8) //fROAR
16060 {
16061 994 temp_mapscr->bosssfx=
16062
2/2
✓ Branch 0 taken 141 times.
✓ Branch 1 taken 853 times.
994 (temp_mapscr->flags3&2) ? WAV_DODONGO : // fDODONGO
16063 853 (temp_mapscr->flags2&32) ? WAV_VADER : // fVADER
16064 WAV_ROAR;
16065 994 }
16066
16067
2/2
✓ Branch 0 taken 170 times.
✓ Branch 1 taken 528334 times.
528504 if(temp_mapscr->flags&128) //fSEA_SFX
16068 {
16069 170 temp_mapscr->oceansfx=WAV_SEA;
16070 170 }
16071
16072 528504 temp_mapscr->secretsfx = (temp_mapscr->flags3&64) //fNOSECRETSOUND
16073 ? 0 : WAV_SECRET;
16074
16075 528504 temp_mapscr->flags3 &= ~66; //64|2
16076 528504 temp_mapscr->flags2 &= ~32;
16077 528504 temp_mapscr->flags &= ~136; // 128|8
16078 528504 }
16079 else
16080 {
16081
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 657968 times.
657968 if(!p_getc(&(temp_mapscr->oceansfx),f))
16082 {
16083 return qe_invalid;
16084 }
16085
16086
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 657968 times.
657968 if(!p_getc(&(temp_mapscr->bosssfx),f))
16087 {
16088 return qe_invalid;
16089 }
16090
16091
1/2
✓ Branch 0 taken 657968 times.
✗ Branch 1 not taken.
657968 if(!p_getc(&(temp_mapscr->secretsfx),f))
16092 {
16093 return qe_invalid;
16094 }
16095 }
16096
16097
2/2
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 657968 times.
1186472 if(version<15) // October 2007: another SFX
16098 {
16099 528504 temp_mapscr->holdupsfx=WAV_PICKUP;
16100 528504 }
16101 else
16102 {
16103
1/2
✓ Branch 0 taken 657968 times.
✗ Branch 1 not taken.
657968 if(!p_getc(&(temp_mapscr->holdupsfx),f))
16104 {
16105 return qe_invalid;
16106 }
16107 }
16108
16109
16110
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1161576 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1186472 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>97)))
16111 {
16112
2/2
✓ Branch 0 taken 6985776 times.
✓ Branch 1 taken 1164296 times.
8150072 for(int32_t k=0; k<6; k++)
16113 {
16114
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6985776 times.
6985776 if(!p_getc(&(temp_mapscr->layermap[k]),f))
16115 {
16116 return qe_invalid;
16117 }
16118 6985776 }
16119
16120
2/2
✓ Branch 0 taken 1164296 times.
✓ Branch 1 taken 6985776 times.
8150072 for(int32_t k=0; k<6; k++)
16121 {
16122
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6985776 times.
6985776 if(!p_getc(&(temp_mapscr->layerscreen[k]),f))
16123 {
16124 return qe_invalid;
16125 }
16126 6985776 }
16127 1164296 }
16128
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 22176 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
22176 else if((Header->zelda_version == 0x192)&&(Header->build>23)&&(Header->build<98))
16129 {
16130 if(!p_getc(&(temp_mapscr->layermap[2]),f))
16131 {
16132 return qe_invalid;
16133 }
16134
16135 if(!p_getc(&(temp_mapscr->layerscreen[2]),f))
16136 {
16137 return qe_invalid;
16138 }
16139
16140 if(!p_getc(&(temp_mapscr->layermap[4]),f))
16141 {
16142 return qe_invalid;
16143 }
16144
16145 if(!p_getc(&(temp_mapscr->layerscreen[4]),f))
16146
16147 {
16148 return qe_invalid;
16149 }
16150 }
16151
16152
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1183752 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1186472 if((Header->zelda_version == 0x192)&&(Header->build>149))
16153 {
16154
2/2
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 2720 times.
19040 for(int32_t k=0; k<6; k++)
16155 {
16156
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layerxsize
16157 {
16158 return qe_invalid;
16159 }
16160 16320 }
16161
16162
2/2
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 2720 times.
19040 for(int32_t k=0; k<6; k++)
16163 {
16164
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layerxspeed
16165 {
16166 return qe_invalid;
16167 }
16168 16320 }
16169
16170
2/2
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 2720 times.
19040 for(int32_t k=0; k<6; k++)
16171 {
16172
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layerxdelay
16173 {
16174 return qe_invalid;
16175 }
16176 16320 }
16177
16178
2/2
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 2720 times.
19040 for(int32_t k=0; k<6; k++)
16179 {
16180
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layerysize
16181 {
16182 return qe_invalid;
16183 }
16184 16320 }
16185
16186
2/2
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 2720 times.
19040 for(int32_t k=0; k<6; k++)
16187 {
16188
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layeryspeed
16189 {
16190 return qe_invalid;
16191 }
16192 16320 }
16193
16194
2/2
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 16320 times.
19040 for(int32_t k=0; k<6; k++)
16195 {
16196
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layerydelay
16197 {
16198 return qe_invalid;
16199 }
16200 16320 }
16201 2720 }
16202
16203
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1161576 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1186472 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>149)))
16204 {
16205
2/2
✓ Branch 0 taken 6985776 times.
✓ Branch 1 taken 1164296 times.
8150072 for(int32_t k=0; k<6; k++)
16206 {
16207
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6985776 times.
6985776 if(!p_getc(&(temp_mapscr->layeropacity[k]),f))
16208 {
16209 return qe_invalid;
16210 }
16211 6985776 }
16212 1164296 }
16213
16214
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1161576 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1186472 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
16215 {
16216
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1161576 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1164296 if((Header->zelda_version == 0x192)&&(Header->build>153))
16217 {
16218
1/2
✓ Branch 0 taken 2720 times.
✗ Branch 1 not taken.
2720 if(!p_getc(&padding,f))
16219 {
16220 return qe_invalid;
16221 }
16222 2720 }
16223
16224
1/2
✓ Branch 0 taken 1164296 times.
✗ Branch 1 not taken.
1164296 if(!p_igetw(&(temp_mapscr->timedwarptics),f))
16225 {
16226 return qe_invalid;
16227 }
16228 1164296 }
16229
16230
5/6
✓ Branch 0 taken 1164296 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1161576 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1186472 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<24)))
16231 {
16232 22176 extras=15;
16233 22176 }
16234
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1161576 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1164296 else if(((Header->zelda_version == 0x192)&&(Header->build<98)))
16235 {
16236 extras=11;
16237 }
16238
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1161576 times.
✓ Branch 2 taken 2720 times.
✗ Branch 3 not taken.
1164296 else if((Header->zelda_version == 0x192)&&(Header->build<150))
16239 {
16240 extras=32;
16241 }
16242
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1161576 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1164296 else if((Header->zelda_version == 0x192)&&(Header->build<154))
16243 {
16244 extras=64;
16245 }
16246
2/2
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1161576 times.
1164296 else if(Header->zelda_version < 0x193)
16247 {
16248 2720 extras=62;
16249 2720 }
16250 else
16251
16252 {
16253 1161576 extras=0;
16254 }
16255
16256
2/2
✓ Branch 0 taken 501280 times.
✓ Branch 1 taken 1186472 times.
1687752 for(int32_t k=0; k<extras; k++)
16257 {
16258
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 501280 times.
501280 if(!p_getc(&tempbyte,f)) //extra[k]
16259 {
16260 return qe_invalid;
16261 }
16262 501280 }
16263
16264
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 657968 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1186472 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>2)))
16265 //if (version>3)
16266 {
16267
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 657968 times.
657968 if(!p_getc(&(temp_mapscr->nextmap),f))
16268 {
16269 return qe_invalid;
16270 }
16271
16272
1/2
✓ Branch 0 taken 657968 times.
✗ Branch 1 not taken.
657968 if(!p_getc(&(temp_mapscr->nextscr),f))
16273 {
16274 return qe_invalid;
16275 }
16276 657968 }
16277 else
16278 {
16279 528504 temp_mapscr->nextmap=0;
16280 528504 temp_mapscr->nextscr=0;
16281 }
16282
16283
5/6
✓ Branch 0 taken 1164296 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1161576 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1186472 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
16284 {
16285 22176 secretcombos=20;
16286 22176 }
16287
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1161576 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1164296 else if((Header->zelda_version == 0x192)&&(Header->build<154))
16288 {
16289 secretcombos=256;
16290 }
16291 else
16292 {
16293 1164296 secretcombos=128;
16294 }
16295
16296
5/6
✓ Branch 0 taken 1164296 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1161576 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1186472 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16297 {
16298
2/2
✓ Branch 0 taken 443520 times.
✓ Branch 1 taken 22176 times.
465696 for(int32_t k=0; k<secretcombos; k++)
16299 {
16300
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 443520 times.
443520 if(!p_getc(&tempbyte,f))
16301 {
16302 return qe_invalid;
16303 }
16304
16305
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 443520 times.
443520 if(k<128)
16306 {
16307 443520 temp_mapscr->secretcombo[k]=tempbyte;
16308 443520 }
16309 443520 }
16310 22176 }
16311 else
16312 {
16313
2/2
✓ Branch 0 taken 149029888 times.
✓ Branch 1 taken 1164296 times.
150194184 for(int32_t k=0; k<128; k++)
16314 {
16315
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 149029888 times.
149029888 if(!p_igetw(&(temp_mapscr->secretcombo[k]),f))
16316 {
16317 return qe_invalid;
16318 }
16319
16320 149029888 }
16321 }
16322
16323
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1161576 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1186472 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
16324 {
16325
2/2
✓ Branch 0 taken 149029888 times.
✓ Branch 1 taken 1164296 times.
150194184 for(int32_t k=0; k<128; k++)
16326 {
16327
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 149029888 times.
149029888 if(!p_getc(&(temp_mapscr->secretcset[k]),f))
16328 {
16329 return qe_invalid;
16330 }
16331 149029888 }
16332
16333
2/2
✓ Branch 0 taken 149029888 times.
✓ Branch 1 taken 1164296 times.
150194184 for(int32_t k=0; k<128; k++)
16334 {
16335
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 149029888 times.
149029888 if(!p_getc(&(temp_mapscr->secretflag[k]),f))
16336 {
16337 return qe_invalid;
16338 }
16339 149029888 }
16340 1164296 }
16341
16342
4/6
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1183752 times.
✓ Branch 2 taken 2720 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1186472 if((Header->zelda_version == 0x192)&&(Header->build>97)&&(Header->build<154))
16343 {
16344 if(!p_getc(&padding,f))
16345 {
16346 return qe_invalid;
16347 }
16348 }
16349
16350
2/2
✓ Branch 0 taken 208819072 times.
✓ Branch 1 taken 1186472 times.
210005544 for(int32_t k=0; k<176; k++)
16351 {
16352
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 208819072 times.
208819072 if(!p_igetw(&(temp_mapscr->data[k]),f))
16353 {
16354 return qe_invalid;
16355 }
16356 208819072 }
16357
16358
4/6
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1183752 times.
✓ Branch 2 taken 2720 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1186472 if((Header->zelda_version == 0x192)&&(Header->build>20)&&(Header->build<24))
16359 {
16360 if(!p_getc(&padding,f))
16361 {
16362 return qe_invalid;
16363 }
16364
16365 if(!p_getc(&padding,f))
16366 {
16367 return qe_invalid;
16368 }
16369 }
16370
16371
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1161576 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1186472 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>20)))
16372 {
16373
2/2
✓ Branch 0 taken 204916096 times.
✓ Branch 1 taken 1164296 times.
206080392 for(int32_t k=0; k<176; k++)
16374 {
16375
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 204916096 times.
204916096 if(!p_getc(&(temp_mapscr->sflag[k]),f))
16376 {
16377 return qe_invalid;
16378 }
16379
16380
3/4
✓ Branch 0 taken 478720 times.
✓ Branch 1 taken 204437376 times.
✓ Branch 2 taken 478720 times.
✗ Branch 3 not taken.
204916096 if((Header->zelda_version == 0x192)&&(Header->build<24))
16381 {
16382 if(!p_getc(&tempbyte,f))
16383 {
16384 return qe_invalid;
16385 }
16386
16387 if(!p_getc(&tempbyte,f))
16388 {
16389 return qe_invalid;
16390 }
16391
16392 if(!p_getc(&tempbyte,f))
16393 {
16394 return qe_invalid;
16395 }
16396 }
16397 204916096 }
16398 1164296 }
16399
16400
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1161576 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1186472 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>97)))
16401 {
16402
2/2
✓ Branch 0 taken 1164296 times.
✓ Branch 1 taken 204916096 times.
206080392 for(int32_t k=0; k<176; k++)
16403 {
16404
16405
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 204916096 times.
204916096 if(!p_getc(&(temp_mapscr->cset[k]),f))
16406 {
16407 return qe_invalid;
16408 }
16409 204916096 }
16410 1164296 }
16411
16412
5/6
✓ Branch 0 taken 1164296 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1161576 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1186472 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16413 {
16414 22176 temp_mapscr->undercset=(temp_mapscr->undercombo>>8)&7;
16415 22176 temp_mapscr->undercombo=(temp_mapscr->undercombo&0xFF)+(old_combo_pages[scrind]<<8);
16416 22176 }
16417
16418
5/6
✓ Branch 0 taken 1164296 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1161576 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1186472 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
16419 {
16420 22176 temp_mapscr->secretcombo[sSBOMB]=temp_mapscr->secretcombo[sBOMB];
16421 22176 temp_mapscr->secretcombo[sRCANDLE]=temp_mapscr->secretcombo[sBCANDLE];
16422 22176 temp_mapscr->secretcombo[sWANDFIRE]=temp_mapscr->secretcombo[sBCANDLE];
16423 22176 temp_mapscr->secretcombo[sDIVINEFIRE]=temp_mapscr->secretcombo[sBCANDLE];
16424 22176 temp_mapscr->secretcombo[sSARROW]=temp_mapscr->secretcombo[sARROW];
16425 22176 temp_mapscr->secretcombo[sGARROW]=temp_mapscr->secretcombo[sARROW];
16426 22176 }
16427
16428
5/6
✓ Branch 0 taken 1164296 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1161576 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1186472 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16429 {
16430
2/2
✓ Branch 0 taken 3902976 times.
✓ Branch 1 taken 22176 times.
3925152 for(int32_t k=0; k<176; k++)
16431 {
16432
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3902976 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3902976 if((Header->zelda_version == 0x192)&&(Header->build>149))
16433 {
16434 if((Header->zelda_version == 0x192)&&(Header->build!=153))
16435 {
16436 temp_mapscr->cset[k]=((temp_mapscr->data[k]>>8)&7);
16437 }
16438 }
16439 else
16440 {
16441
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3902976 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3902976 if((Header->zelda_version < 0x192)||
16442 ((Header->zelda_version == 0x192)&&(Header->build<21)))
16443 {
16444 3902976 temp_mapscr->sflag[k]=(temp_mapscr->data[k]>>11);
16445 3902976 }
16446
16447 3902976 temp_mapscr->cset[k]=((temp_mapscr->data[k]>>8)&7);
16448 }
16449
16450 3902976 temp_mapscr->data[k]=(temp_mapscr->data[k]&0xFF)+(old_combo_pages[scrind]<<8);
16451 3902976 }
16452 22176 }
16453
16454 /*if(version>12)
16455 {
16456 if(!p_getc(&(temp_mapscr->scrWidth),f))
16457 {
16458 return qe_invalid;
16459 }
16460 if(!p_getc(&(temp_mapscr->scrHeight),f))
16461 {
16462 return qe_invalid;
16463 }
16464 }*/
16465
16466
2/2
✓ Branch 0 taken 657968 times.
✓ Branch 1 taken 528504 times.
1186472 if(version>4)
16467 {
16468
1/2
✓ Branch 0 taken 657968 times.
✗ Branch 1 not taken.
657968 if(!p_igetw(&(temp_mapscr->screen_midi),f))
16469 {
16470 return qe_invalid;
16471 }
16472 657968 }
16473 else
16474 {
16475 528504 temp_mapscr->screen_midi = -1;
16476 }
16477
16478
2/2
✓ Branch 0 taken 657968 times.
✓ Branch 1 taken 528504 times.
1186472 if(version>=17)
16479 {
16480
1/2
✓ Branch 0 taken 657968 times.
✗ Branch 1 not taken.
657968 if(!p_getc(&(temp_mapscr->lens_layer),f))
16481 {
16482 return qe_invalid;
16483 }
16484 657968 }
16485 else
16486 {
16487 528504 temp_mapscr->lens_layer = llNORMAL;
16488 }
16489
16490
2/2
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 657968 times.
1186472 if(version>6)
16491 {
16492 dword bits;
16493
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 657968 times.
657968 if(!p_igetl(&bits,f))
16494 {
16495 return qe_invalid;
16496 }
16497
16498 int32_t m;
16499 float tempfloat;
16500 word tempw;
16501 657968 temp_mapscr->ffcCountMarkDirty();
16502 657968 temp_mapscr->ffcs.clear();
16503 657968 temp_mapscr->resizeFFC(std::bit_width(bits));
16504
2/2
✓ Branch 0 taken 657968 times.
✓ Branch 1 taken 21054976 times.
21712944 for(m=0; m<32; m++)
16505 {
16506
2/2
✓ Branch 0 taken 20778977 times.
✓ Branch 1 taken 275999 times.
21054976 if((bits>>m)&1)
16507 {
16508 275999 ffcdata& tempffc = temp_mapscr->ffcs[m];
16509
1/2
✓ Branch 0 taken 275999 times.
✗ Branch 1 not taken.
275999 if(!p_igetw(&tempw,f))
16510 {
16511 return qe_invalid;
16512 }
16513 275999 tempffc.data = tempw;
16514
16515
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_getc(&(tempffc.cset),f))
16516 {
16517 return qe_invalid;
16518 }
16519
16520
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_igetw(&(tempffc.delay),f))
16521 {
16522 return qe_invalid;
16523 }
16524
16525
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(version < 9)
16526 {
16527 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16528 {
16529 return qe_invalid;
16530 }
16531
16532 tempffc.x=zslongToFix(int32_t(tempfloat*10000));
16533
16534 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16535 {
16536 return qe_invalid;
16537 }
16538
16539 tempffc.y=zslongToFix(int32_t(tempfloat*10000));
16540
16541 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16542 {
16543 return qe_invalid;
16544 }
16545
16546 tempffc.vx=zslongToFix(int32_t(tempfloat*10000));
16547
16548 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16549 {
16550 return qe_invalid;
16551 }
16552
16553 tempffc.vy=zslongToFix(int32_t(tempfloat*10000));
16554
16555 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16556 {
16557 return qe_invalid;
16558 }
16559
16560 tempffc.ax=zslongToFix(int32_t(tempfloat*10000));
16561
16562 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16563 {
16564 return qe_invalid;
16565 }
16566
16567 tempffc.ay=zslongToFix(int32_t(tempfloat*10000));
16568 }
16569 else
16570 {
16571
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_igetzf(&(tempffc.x),f))
16572 {
16573 return qe_invalid;
16574 }
16575
16576
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_igetzf(&(tempffc.y),f))
16577 {
16578 return qe_invalid;
16579 }
16580
16581
1/2
✓ Branch 0 taken 275999 times.
✗ Branch 1 not taken.
275999 if(!p_igetzf(&(tempffc.vx),f))
16582 {
16583 return qe_invalid;
16584 }
16585
16586
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_igetzf(&(tempffc.vy),f))
16587 {
16588 return qe_invalid;
16589 }
16590
16591
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_igetzf(&(tempffc.ax),f))
16592 {
16593 return qe_invalid;
16594 }
16595
16596
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_igetzf(&(tempffc.ay),f))
16597 {
16598 return qe_invalid;
16599 }
16600 }
16601
16602
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_getc(&(tempffc.link),f))
16603 {
16604 return qe_invalid;
16605 }
16606
16607
1/2
✓ Branch 0 taken 275999 times.
✗ Branch 1 not taken.
275999 if(version>7)
16608 {
16609
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_getc(&tempbyte,f))
16610 {
16611 return qe_invalid;
16612 }
16613
16614 275999 tempffc.hit_width = (tempbyte&0x3F)+1;
16615 275999 tempffc.txsz = (tempbyte>>6)+1;
16616
16617
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_getc(&tempbyte,f))
16618 {
16619 return qe_invalid;
16620 }
16621
16622 275999 tempffc.hit_height = (tempbyte&0x3F)+1;
16623 275999 tempffc.tysz = (tempbyte>>6)+1;
16624
16625
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_igetl(&(tempffc.flags),f))
16626 {
16627 return qe_invalid;
16628 }
16629 275999 }
16630 else
16631 {
16632 tempffc.hit_width=16;
16633 tempffc.hit_height=16;
16634 tempffc.txsz=1;
16635 tempffc.tysz=1;
16636 tempffc.flags=ffc_none;
16637 }
16638
16639 275999 tempffc.updateSolid();
16640
16641
16642
4/6
✓ Branch 0 taken 275999 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 269995 times.
✓ Branch 3 taken 6004 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 269995 times.
275999 if(Header->zelda_version == 0x211 || (Header->zelda_version == 0x250 && Header->build<20))
16643 {
16644 tempffc.flags|=ffc_ignoreholdup;
16645 }
16646
16647
1/2
✓ Branch 0 taken 275999 times.
✗ Branch 1 not taken.
275999 if(version>9)
16648 {
16649
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_igetw(&(tempffc.script),f))
16650 {
16651 return qe_invalid;
16652 }
16653 275999 }
16654 else
16655 {
16656 tempffc.script=0;
16657 }
16658
16659
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(version>10)
16660 {
16661
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_igetl(&(tempffc.initd[0]),f))
16662 {
16663 return qe_invalid;
16664 }
16665
16666
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_igetl(&(tempffc.initd[1]),f))
16667 {
16668 return qe_invalid;
16669 }
16670
16671
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_igetl(&(tempffc.initd[2]),f))
16672 {
16673 return qe_invalid;
16674 }
16675
16676
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_igetl(&(tempffc.initd[3]),f))
16677 {
16678 return qe_invalid;
16679 }
16680
16681
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_igetl(&(tempffc.initd[4]),f))
16682 {
16683 return qe_invalid;
16684 }
16685
16686
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_igetl(&(tempffc.initd[5]),f))
16687 {
16688 return qe_invalid;
16689 }
16690
16691
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_igetl(&(tempffc.initd[6]),f))
16692 {
16693 return qe_invalid;
16694 }
16695
16696
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_igetl(&(tempffc.initd[7]),f))
16697 {
16698 return qe_invalid;
16699 }
16700
16701
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_getc(&(tempbyte),f))
16702 {
16703 return qe_invalid;
16704 }
16705
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_getc(&(tempbyte),f))
16706 {
16707 return qe_invalid;
16708 }
16709 275999 }
16710
16711
1/2
✓ Branch 0 taken 275999 times.
✗ Branch 1 not taken.
275999 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
16712 {
16713 tempffc.script = 0;
16714 for(int q = 0; q < 8; ++q)
16715 tempffc.initd[q] = 0;
16716 }
16717
1/2
✓ Branch 0 taken 275999 times.
✗ Branch 1 not taken.
275999 if(version <= 11)
16718 {
16719 fixffcs=true;
16720 }
16721 275999 }
16722 21054976 }
16723
16724 657968 temp_mapscr->shinkToFitFFCs();
16725 657968 }
16726
16727
16728 //add in the new whistle flags
16729
2/2
✓ Branch 0 taken 657968 times.
✓ Branch 1 taken 528504 times.
1186472 if(version<13)
16730 {
16731
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 528380 times.
528504 if(temp_mapscr->flags & fWHISTLE)
16732 {
16733 124 temp_mapscr->flags7 |= (fWHISTLEPAL | fWHISTLEWATER);
16734 124 }
16735 528504 }
16736
16737 //2.55 starts here
16738
3/4
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1152064 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34408 times.
1186472 if ( version >= 19 && Header->zelda_version > 0x253 )
16739 {
16740 // mapscr fields that were never used, so are now removed:
16741 // int32_t npcstrings[10];
16742 // int16_t new_items[10];
16743 // int16_t new_item_x[10];
16744 // int16_t new_item_y[10];
16745
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34408 times.
34408 if (pack_fseek(f, 100))
16746 {
16747 return qe_invalid;
16748 }
16749 34408 }
16750
16751
3/4
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1152064 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34408 times.
1186472 if ( version >= 20 && Header->zelda_version > 0x253 )
16752 {
16753
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34408 times.
34408 if(!p_igetw(&(temp_mapscr->script),f))
16754 {
16755 return qe_invalid;
16756 }
16757
2/2
✓ Branch 0 taken 275264 times.
✓ Branch 1 taken 34408 times.
309672 for ( int32_t q = 0; q < 8; q++)
16758 {
16759
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275264 times.
275264 if(!p_igetl(&(temp_mapscr->screeninitd[q]),f))
16760 {
16761 return qe_invalid;
16762 }
16763 275264 }
16764 34408 }
16765
2/2
✓ Branch 0 taken 1152064 times.
✓ Branch 1 taken 34408 times.
1186472 if ( version < 20 )
16766 {
16767 1152064 temp_mapscr->script = 0;
16768
2/2
✓ Branch 0 taken 9216512 times.
✓ Branch 1 taken 1152064 times.
10368576 for ( int32_t q = 0; q < 8; q++) temp_mapscr->screeninitd[q] = 0;
16769 1152064 }
16770
3/4
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1152064 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34408 times.
1186472 if ( version >= 21 && Header->zelda_version > 0x253 )
16771 {
16772
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34408 times.
34408 if(!p_getc(&(temp_mapscr->preloadscript),f))
16773 {
16774 return qe_invalid;
16775 }
16776 34408 }
16777
2/2
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1152064 times.
1186472 if ( version < 21 )
16778 {
16779 1152064 temp_mapscr->preloadscript = 0;
16780 1152064 }
16781
16782
3/4
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1152064 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34408 times.
1186472 if ( version >= 22 && Header->zelda_version > 0x253 ) //26th June, 2019; Layer Visibility
16783 {
16784
1/2
✓ Branch 0 taken 34408 times.
✗ Branch 1 not taken.
34408 if(!p_getc(&(temp_mapscr->hidelayers ),f))
16785 {
16786 return qe_invalid;
16787 }
16788
1/2
✓ Branch 0 taken 34408 times.
✗ Branch 1 not taken.
34408 if(!p_getc(&(temp_mapscr->hidescriptlayers ),f))
16789 {
16790 return qe_invalid;
16791 }
16792 34408 }
16793
2/2
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1152064 times.
1186472 if ( version < 22 )
16794 {
16795 1152064 temp_mapscr->hidelayers = 0;
16796 1152064 temp_mapscr->hidescriptlayers = 0;
16797 1152064 }
16798
16799 //Dodongos in 2.10 used the boss roar, not the dodongo sound. -Z
16800 //May be any version before 2.11. -Z
16801 /* --not the roar, the HIT SFX
16802 if ( Header->zelda_version <= 0x210 )
16803 {
16804 if ( temp_mapscr->bosssfx == WAV_DODONGO )
16805 {
16806 temp_mapscr->bosssfx = WAV_ROAR;
16807 }
16808 }
16809 */
16810
2/2
✓ Branch 0 taken 4745888 times.
✓ Branch 1 taken 1186472 times.
5932360 for(int32_t k=0; k<4; k++)
16811 {
16812
1/2
✓ Branch 0 taken 4745888 times.
✗ Branch 1 not taken.
4745888 if(temp_mapscr->door[k] == dNONE)
16813 temp_mapscr->door[k] = dWALL;
16814 4745888 }
16815
16816 1186472 return 0;
16817 1186472 }
16818 1388840 int32_t readmapscreen(PACKFILE *f, zquestheader *Header, mapscr *temp_mapscr, word version, int scrind)
16819 {
16820
2/2
✓ Branch 0 taken 1186472 times.
✓ Branch 1 taken 202368 times.
1388840 if(version < 23)
16821 {
16822 1186472 auto ret = readmapscreen_old(f,Header,temp_mapscr,version,scrind);
16823
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186472 times.
1186472 if(ret) return ret;
16824 1186472 }
16825 else
16826 {
16827
1/2
✓ Branch 0 taken 202368 times.
✗ Branch 1 not taken.
202368 if(!p_getc(&(temp_mapscr->valid),f))
16828 return qe_invalid;
16829
2/2
✓ Branch 0 taken 105983 times.
✓ Branch 1 taken 96385 times.
202368 if(!(temp_mapscr->valid & mVALID))
16830 {
16831 96385 int map = scrind/MAPSCRS;
16832 96385 int screen = scrind%MAPSCRS;
16833
4/6
✓ Branch 0 taken 89283 times.
✓ Branch 1 taken 7102 times.
✓ Branch 2 taken 89283 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 89283 times.
96385 if(version > 25 && scrind > -1 && (map*6+5) < map_autolayers.size())
16834 {
16835 //Empty screen, apply autolayers
16836
2/2
✓ Branch 0 taken 535698 times.
✓ Branch 1 taken 89283 times.
624981 for(int q = 0; q < 6; ++q)
16837 {
16838 535698 auto layermap = map_autolayers[map*6+q];
16839 535698 temp_mapscr->layermap[q] = layermap;
16840
2/2
✓ Branch 0 taken 520155 times.
✓ Branch 1 taken 15543 times.
535698 if(layermap)
16841 15543 temp_mapscr->layerscreen[q] = screen;
16842 535698 }
16843 89283 }
16844 96385 return 0;
16845 }
16846 uint32_t scr_has_flags;
16847
1/2
✓ Branch 0 taken 105983 times.
✗ Branch 1 not taken.
105983 if(!p_igetl(&scr_has_flags,f))
16848 return qe_invalid;
16849
16850
2/2
✓ Branch 0 taken 10458 times.
✓ Branch 1 taken 95525 times.
105983 if(scr_has_flags & SCRHAS_ROOMDATA)
16851 {
16852
1/2
✓ Branch 0 taken 95525 times.
✗ Branch 1 not taken.
95525 if(!p_getc(&(temp_mapscr->guy),f))
16853 return qe_invalid;
16854
2/2
✓ Branch 0 taken 95405 times.
✓ Branch 1 taken 120 times.
95525 if(version > 26)
16855 {
16856
1/2
✓ Branch 0 taken 95405 times.
✗ Branch 1 not taken.
95405 if(!p_igetl(&(temp_mapscr->guytile),f))
16857 return qe_invalid;
16858
1/2
✓ Branch 0 taken 95405 times.
✗ Branch 1 not taken.
95405 if(!p_getc(&(temp_mapscr->guycs),f))
16859 return qe_invalid;
16860
1/2
✓ Branch 0 taken 95405 times.
✗ Branch 1 not taken.
95405 if(!p_igetw(&(temp_mapscr->roomflags),f))
16861 return qe_invalid;
16862 95405 }
16863 else
16864 {
16865 120 temp_mapscr->guytile = -1; //signal to use default guy values
16866
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 SETFLAG(temp_mapscr->roomflags,RFL_ALWAYS_GUY,temp_mapscr->guy==gFAIRY);
16867
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
120 SETFLAG(temp_mapscr->roomflags,RFL_GUYFIRES,temp_mapscr->guy!=gFAIRY || !get_qr(qr_NOFAIRYGUYFIRES));
16868 }
16869
1/2
✓ Branch 0 taken 95525 times.
✗ Branch 1 not taken.
95525 if(!p_igetw(&(temp_mapscr->str),f))
16870 return qe_invalid;
16871
1/2
✓ Branch 0 taken 95525 times.
✗ Branch 1 not taken.
95525 if(!p_getc(&(temp_mapscr->room),f))
16872 return qe_invalid;
16873
1/2
✓ Branch 0 taken 95525 times.
✗ Branch 1 not taken.
95525 if(!p_igetw(&(temp_mapscr->catchall),f))
16874 return qe_invalid;
16875 95525 }
16876
2/2
✓ Branch 0 taken 103624 times.
✓ Branch 1 taken 2359 times.
105983 if(scr_has_flags & SCRHAS_ITEM)
16877 {
16878
1/2
✓ Branch 0 taken 2359 times.
✗ Branch 1 not taken.
2359 if(!p_getc(&(temp_mapscr->item),f))
16879 return qe_invalid;
16880
1/2
✓ Branch 0 taken 2359 times.
✗ Branch 1 not taken.
2359 if(!p_getc(&(temp_mapscr->hasitem),f))
16881 return qe_invalid;
16882
1/2
✓ Branch 0 taken 2359 times.
✗ Branch 1 not taken.
2359 if(!p_getc(&(temp_mapscr->itemx),f))
16883 return qe_invalid;
16884
1/2
✓ Branch 0 taken 2359 times.
✗ Branch 1 not taken.
2359 if(!p_getc(&(temp_mapscr->itemy),f))
16885 return qe_invalid;
16886 2359 }
16887
2/2
✓ Branch 0 taken 95324 times.
✓ Branch 1 taken 10659 times.
105983 if(scr_has_flags & (SCRHAS_SWARP|SCRHAS_TWARP))
16888 {
16889
1/2
✓ Branch 0 taken 10659 times.
✗ Branch 1 not taken.
10659 if(!p_igetw(&temp_mapscr->warpreturnc,f))
16890 return qe_invalid;
16891 10659 }
16892
2/2
✓ Branch 0 taken 103503 times.
✓ Branch 1 taken 2480 times.
105983 if(scr_has_flags & SCRHAS_TWARP)
16893 {
16894
2/2
✓ Branch 0 taken 9920 times.
✓ Branch 1 taken 2480 times.
12400 for(int32_t i=0; i<4; i++)
16895 {
16896
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9920 times.
9920 if(!p_getc(&(temp_mapscr->tilewarptype[i]),f))
16897 return qe_invalid;
16898 9920 }
16899
2/2
✓ Branch 0 taken 9920 times.
✓ Branch 1 taken 2480 times.
12400 for(int32_t i=0; i<4; i++)
16900 {
16901
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9920 times.
9920 if(!p_igetw(&(temp_mapscr->tilewarpdmap[i]),f))
16902 return qe_invalid;
16903 9920 }
16904
2/2
✓ Branch 0 taken 9920 times.
✓ Branch 1 taken 2480 times.
12400 for(int32_t i=0; i<4; i++)
16905 {
16906
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9920 times.
9920 if(!p_getc(&(temp_mapscr->tilewarpscr[i]),f))
16907 return qe_invalid;
16908 9920 }
16909
1/2
✓ Branch 0 taken 2480 times.
✗ Branch 1 not taken.
2480 if(!p_getc(&(temp_mapscr->tilewarpoverlayflags),f))
16910 return qe_invalid;
16911 2480 }
16912
2/2
✓ Branch 0 taken 97329 times.
✓ Branch 1 taken 8654 times.
105983 if(scr_has_flags & SCRHAS_SWARP)
16913 {
16914
2/2
✓ Branch 0 taken 34616 times.
✓ Branch 1 taken 8654 times.
43270 for(int32_t i=0; i<4; i++)
16915 {
16916
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34616 times.
34616 if(!p_getc(&(temp_mapscr->sidewarptype[i]),f))
16917 return qe_invalid;
16918 34616 }
16919
2/2
✓ Branch 0 taken 34616 times.
✓ Branch 1 taken 8654 times.
43270 for(int32_t i=0; i<4; i++)
16920 {
16921
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34616 times.
34616 if(!p_igetw(&(temp_mapscr->sidewarpdmap[i]),f))
16922 return qe_invalid;
16923 34616 }
16924
2/2
✓ Branch 0 taken 34616 times.
✓ Branch 1 taken 8654 times.
43270 for(int32_t i=0; i<4; i++)
16925 {
16926
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34616 times.
34616 if(!p_getc(&(temp_mapscr->sidewarpscr[i]),f))
16927 return qe_invalid;
16928 34616 }
16929
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8654 times.
8654 if(!p_getc(&(temp_mapscr->sidewarpoverlayflags),f))
16930 return qe_invalid;
16931
1/2
✓ Branch 0 taken 8654 times.
✗ Branch 1 not taken.
8654 if(!p_getc(&(temp_mapscr->sidewarpindex),f))
16932 return qe_invalid;
16933 8654 }
16934
2/2
✓ Branch 0 taken 99380 times.
✓ Branch 1 taken 6603 times.
105983 if(scr_has_flags & SCRHAS_WARPRET)
16935 {
16936
2/2
✓ Branch 0 taken 26412 times.
✓ Branch 1 taken 6603 times.
33015 for(int32_t i=0; i<4; i++)
16937 {
16938
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26412 times.
26412 if(!p_getc(&(temp_mapscr->warpreturnx[i]),f))
16939 return qe_invalid;
16940 26412 }
16941
2/2
✓ Branch 0 taken 26412 times.
✓ Branch 1 taken 6603 times.
33015 for(int32_t i=0; i<4; i++)
16942 {
16943
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26412 times.
26412 if(!p_getc(&(temp_mapscr->warpreturny[i]),f))
16944 return qe_invalid;
16945 26412 }
16946
1/2
✓ Branch 0 taken 6603 times.
✗ Branch 1 not taken.
6603 if(!p_getc(&(temp_mapscr->warparrivalx),f))
16947 return qe_invalid;
16948
1/2
✓ Branch 0 taken 6603 times.
✗ Branch 1 not taken.
6603 if(!p_getc(&(temp_mapscr->warparrivaly),f))
16949 return qe_invalid;
16950 6603 }
16951
2/2
✓ Branch 0 taken 92475 times.
✓ Branch 1 taken 13508 times.
105983 if(scr_has_flags & SCRHAS_LAYERS)
16952 {
16953
2/2
✓ Branch 0 taken 81048 times.
✓ Branch 1 taken 13508 times.
94556 for(int32_t k=0; k<6; k++)
16954 {
16955
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 81048 times.
81048 if(!p_getc(&(temp_mapscr->layermap[k]),f))
16956 return qe_invalid;
16957 81048 }
16958
2/2
✓ Branch 0 taken 81048 times.
✓ Branch 1 taken 13508 times.
94556 for(int32_t k=0; k<6; k++)
16959 {
16960
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 81048 times.
81048 if(!p_getc(&(temp_mapscr->layerscreen[k]),f))
16961 return qe_invalid;
16962 81048 }
16963
2/2
✓ Branch 0 taken 81048 times.
✓ Branch 1 taken 13508 times.
94556 for(int32_t k=0; k<6; k++)
16964 {
16965
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 81048 times.
81048 if(!p_getc(&(temp_mapscr->layeropacity[k]),f))
16966 return qe_invalid;
16967 81048 }
16968
1/2
✓ Branch 0 taken 13508 times.
✗ Branch 1 not taken.
13508 if(!p_getc(&(temp_mapscr->hidelayers),f))
16969 return qe_invalid;
16970
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13508 times.
13508 if(!p_getc(&(temp_mapscr->hidescriptlayers),f))
16971 return qe_invalid;
16972 13508 }
16973
2/2
✓ Branch 0 taken 105879 times.
✓ Branch 1 taken 104 times.
105983 if(scr_has_flags & SCRHAS_MAZE)
16974 {
16975
2/2
✓ Branch 0 taken 416 times.
✓ Branch 1 taken 104 times.
520 for(int32_t k=0; k<4; k++)
16976 {
16977
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 416 times.
416 if(!p_getc(&(temp_mapscr->path[k]),f))
16978 return qe_invalid;
16979 416 }
16980
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if(!p_getc(&(temp_mapscr->exitdir),f))
16981 return qe_invalid;
16982
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if (version >= 32)
16983 {
16984
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if (!p_getc(&temp_mapscr->maze_transition_wipe, f))
16985 return qe_invalid;
16986 104 }
16987 104 }
16988
2/2
✓ Branch 0 taken 77250 times.
✓ Branch 1 taken 28733 times.
105983 if(scr_has_flags & SCRHAS_D_S_U)
16989 {
16990
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77250 times.
77250 if(!p_igetw(&(temp_mapscr->door_combo_set),f))
16991 return qe_invalid;
16992
2/2
✓ Branch 0 taken 309000 times.
✓ Branch 1 taken 77250 times.
386250 for(int32_t k=0; k<4; k++)
16993 {
16994
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 309000 times.
309000 if(!p_getc(&(temp_mapscr->door[k]),f))
16995 return qe_invalid;
16996
3/4
✓ Branch 0 taken 360 times.
✓ Branch 1 taken 308640 times.
✓ Branch 2 taken 360 times.
✗ Branch 3 not taken.
309000 if(version < 29 && temp_mapscr->door[k] == dNONE)
16997 temp_mapscr->door[k] = dWALL;
16998 309000 }
16999
17000
1/2
✓ Branch 0 taken 77250 times.
✗ Branch 1 not taken.
77250 if(!p_getc(&(temp_mapscr->stairx),f))
17001 return qe_invalid;
17002
17003
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77250 times.
77250 if(!p_getc(&(temp_mapscr->stairy),f))
17004 return qe_invalid;
17005
1/2
✓ Branch 0 taken 77250 times.
✗ Branch 1 not taken.
77250 if(!p_igetw(&(temp_mapscr->undercombo),f))
17006 return qe_invalid;
17007
1/2
✓ Branch 0 taken 77250 times.
✗ Branch 1 not taken.
77250 if(!p_getc(&(temp_mapscr->undercset),f))
17008 return qe_invalid;
17009 77250 }
17010
2/2
✓ Branch 0 taken 10488 times.
✓ Branch 1 taken 18245 times.
28733 else if(version < 29)
17011 {
17012
2/2
✓ Branch 0 taken 41952 times.
✓ Branch 1 taken 10488 times.
52440 for(int k = 0; k < 4; ++k)
17013 41952 temp_mapscr->door[k] = dWALL;
17014 10488 }
17015
2/2
✓ Branch 0 taken 99516 times.
✓ Branch 1 taken 6467 times.
105983 if(scr_has_flags & SCRHAS_FLAGS)
17016 {
17017
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6467 times.
6467 if(!p_getc(&(temp_mapscr->flags),f))
17018 return qe_invalid;
17019
1/2
✓ Branch 0 taken 6467 times.
✗ Branch 1 not taken.
6467 if(!p_getc(&(temp_mapscr->flags2),f))
17020 return qe_invalid;
17021
1/2
✓ Branch 0 taken 6467 times.
✗ Branch 1 not taken.
6467 if(!p_getc(&(temp_mapscr->flags3),f))
17022 return qe_invalid;
17023
1/2
✓ Branch 0 taken 6467 times.
✗ Branch 1 not taken.
6467 if(!p_getc(&(temp_mapscr->flags4),f))
17024 return qe_invalid;
17025
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6467 times.
6467 if(!p_getc(&(temp_mapscr->flags5),f))
17026 return qe_invalid;
17027
1/2
✓ Branch 0 taken 6467 times.
✗ Branch 1 not taken.
6467 if(!p_getc(&(temp_mapscr->flags6),f))
17028 return qe_invalid;
17029
1/2
✓ Branch 0 taken 6467 times.
✗ Branch 1 not taken.
6467 if(!p_getc(&(temp_mapscr->flags7),f))
17030 return qe_invalid;
17031
1/2
✓ Branch 0 taken 6467 times.
✗ Branch 1 not taken.
6467 if(!p_getc(&(temp_mapscr->flags8),f))
17032 return qe_invalid;
17033
1/2
✓ Branch 0 taken 6467 times.
✗ Branch 1 not taken.
6467 if(!p_getc(&(temp_mapscr->flags9),f))
17034 return qe_invalid;
17035
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6467 times.
6467 if(!p_getc(&(temp_mapscr->flags10),f))
17036 return qe_invalid;
17037
1/2
✓ Branch 0 taken 6467 times.
✗ Branch 1 not taken.
6467 if(!p_getc(&(temp_mapscr->flags11),f))
17038 return qe_invalid;
17039 6467 }
17040
2/2
✓ Branch 0 taken 100704 times.
✓ Branch 1 taken 5279 times.
105983 if(scr_has_flags & SCRHAS_ENEMY)
17041 {
17042
2/2
✓ Branch 0 taken 52790 times.
✓ Branch 1 taken 5279 times.
58069 for(int32_t k=0; k<10; k++)
17043 {
17044
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52790 times.
52790 if(!p_igetw(&(temp_mapscr->enemy[k]),f))
17045 return qe_invalid;
17046
1/2
✓ Branch 0 taken 52790 times.
✗ Branch 1 not taken.
52790 if (unsigned(temp_mapscr->enemy[k]) > MAXGUYS)
17047 temp_mapscr->enemy[k] = 0;
17048 52790 }
17049
1/2
✓ Branch 0 taken 5279 times.
✗ Branch 1 not taken.
5279 if(!p_getc(&(temp_mapscr->pattern),f))
17050 return qe_invalid;
17051 5279 }
17052
2/2
✓ Branch 0 taken 105578 times.
✓ Branch 1 taken 405 times.
105983 if(scr_has_flags & SCRHAS_CARRY)
17053 {
17054
1/2
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
405 if(!p_igetw(&(temp_mapscr->noreset),f))
17055 return qe_invalid;
17056
1/2
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
405 if(!p_igetw(&(temp_mapscr->nocarry),f))
17057 return qe_invalid;
17058
1/2
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
405 if(!p_getc(&(temp_mapscr->nextmap),f))
17059 return qe_invalid;
17060
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 405 times.
405 if(!p_getc(&(temp_mapscr->nextscr),f))
17061 return qe_invalid;
17062 405 }
17063
2/2
✓ Branch 0 taken 105398 times.
✓ Branch 1 taken 585 times.
105983 if(scr_has_flags & SCRHAS_SCRIPT)
17064 {
17065
1/2
✓ Branch 0 taken 585 times.
✗ Branch 1 not taken.
585 if(!p_igetw(&(temp_mapscr->script),f))
17066 return qe_invalid;
17067
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 585 times.
585 if(!p_getc(&(temp_mapscr->preloadscript),f))
17068 return qe_invalid;
17069
2/2
✓ Branch 0 taken 4680 times.
✓ Branch 1 taken 585 times.
5265 for ( int32_t q = 0; q < 8; q++ )
17070 {
17071
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4680 times.
4680 if(!p_igetl(&(temp_mapscr->screeninitd[q]),f))
17072 return qe_invalid;
17073 4680 }
17074 585 }
17075
2/2
✓ Branch 0 taken 74524 times.
✓ Branch 1 taken 31459 times.
105983 if(scr_has_flags & SCRHAS_SECRETS)
17076 {
17077
2/2
✓ Branch 0 taken 4026752 times.
✓ Branch 1 taken 31459 times.
4058211 for(int32_t k=0; k<128; k++)
17078 {
17079
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4026752 times.
4026752 if(!p_igetw(&(temp_mapscr->secretcombo[k]),f))
17080 return qe_invalid;
17081 4026752 }
17082
2/2
✓ Branch 0 taken 4026752 times.
✓ Branch 1 taken 31459 times.
4058211 for(int32_t k=0; k<128; k++)
17083 {
17084
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4026752 times.
4026752 if(!p_getc(&(temp_mapscr->secretcset[k]),f))
17085 return qe_invalid;
17086 4026752 }
17087
2/2
✓ Branch 0 taken 4026752 times.
✓ Branch 1 taken 31459 times.
4058211 for(int32_t k=0; k<128; k++)
17088 {
17089
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4026752 times.
4026752 if(!p_getc(&(temp_mapscr->secretflag[k]),f))
17090 return qe_invalid;
17091 4026752 }
17092 31459 }
17093
2/2
✓ Branch 0 taken 40660 times.
✓ Branch 1 taken 65323 times.
105983 if(scr_has_flags & SCRHAS_COMBOFLAG)
17094 {
17095
2/2
✓ Branch 0 taken 11496848 times.
✓ Branch 1 taken 65323 times.
11562171 for(int32_t k=0; k<176; ++k)
17096 {
17097
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11496848 times.
11496848 if(!p_igetw(&(temp_mapscr->data[k]),f))
17098 return qe_invalid;
17099 11496848 }
17100
2/2
✓ Branch 0 taken 11496848 times.
✓ Branch 1 taken 65323 times.
11562171 for(int32_t k=0; k<176; ++k)
17101 {
17102
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11496848 times.
11496848 if(!p_getc(&(temp_mapscr->sflag[k]),f))
17103 return qe_invalid;
17104 11496848 }
17105
2/2
✓ Branch 0 taken 11496848 times.
✓ Branch 1 taken 65323 times.
11562171 for(int32_t k=0; k<176; ++k)
17106 {
17107
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11496848 times.
11496848 if(!p_getc(&(temp_mapscr->cset[k]),f))
17108 return qe_invalid;
17109 11496848 }
17110 65323 }
17111
1/2
✓ Branch 0 taken 105983 times.
✗ Branch 1 not taken.
105983 if(scr_has_flags & SCRHAS_MISC)
17112 {
17113
1/2
✓ Branch 0 taken 105983 times.
✗ Branch 1 not taken.
105983 if(!p_igetw(&(temp_mapscr->color),f))
17114 return qe_invalid;
17115
1/2
✓ Branch 0 taken 105983 times.
✗ Branch 1 not taken.
105983 if(!p_getc(&(temp_mapscr->csensitive),f))
17116 return qe_invalid;
17117
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105983 times.
105983 if(!p_getc(&(temp_mapscr->oceansfx),f))
17118 return qe_invalid;
17119
1/2
✓ Branch 0 taken 105983 times.
✗ Branch 1 not taken.
105983 if(!p_getc(&(temp_mapscr->bosssfx),f))
17120 return qe_invalid;
17121
1/2
✓ Branch 0 taken 105983 times.
✗ Branch 1 not taken.
105983 if(!p_getc(&(temp_mapscr->secretsfx),f))
17122 return qe_invalid;
17123
1/2
✓ Branch 0 taken 105983 times.
✗ Branch 1 not taken.
105983 if(!p_getc(&(temp_mapscr->holdupsfx),f))
17124 return qe_invalid;
17125
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105983 times.
105983 if(!p_igetw(&(temp_mapscr->timedwarptics),f))
17126 return qe_invalid;
17127
1/2
✓ Branch 0 taken 105983 times.
✗ Branch 1 not taken.
105983 if(!p_igetw(&(temp_mapscr->screen_midi),f))
17128 return qe_invalid;
17129
1/2
✓ Branch 0 taken 105983 times.
✗ Branch 1 not taken.
105983 if(!p_getc(&(temp_mapscr->lens_layer),f))
17130 return qe_invalid;
17131
2/2
✓ Branch 0 taken 10578 times.
✓ Branch 1 taken 95405 times.
105983 if(version > 27)
17132 {
17133
1/2
✓ Branch 0 taken 95405 times.
✗ Branch 1 not taken.
95405 if(!p_getc(&(temp_mapscr->lens_show),f))
17134 return qe_invalid;
17135
1/2
✓ Branch 0 taken 95405 times.
✗ Branch 1 not taken.
95405 if(!p_getc(&(temp_mapscr->lens_hide),f))
17136 return qe_invalid;
17137 95405 }
17138 105983 }
17139 else
17140 {
17141 temp_mapscr->screen_midi = -1;
17142 temp_mapscr->csensitive = 1;
17143 }
17144 //FFC
17145 105983 bool old_ff = version < 25;
17146 105983 dword bits = 0;
17147 105983 word numffc = 32;
17148
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105983 times.
105983 if(old_ff)
17149 {
17150 if(!p_igetl(&bits,f))
17151 return qe_invalid;
17152 }
17153 else
17154 {
17155
2/4
✓ Branch 0 taken 105983 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 105983 times.
105983 if(!p_igetw(&numffc,f) || numffc > MAXFFCS)
17156 return qe_invalid;
17157 }
17158
17159 105983 temp_mapscr->ffcCountMarkDirty();
17160 105983 temp_mapscr->ffcs.clear();
17161 105983 temp_mapscr->resizeFFC(numffc);
17162
17163 byte tempbyte;
17164 word tempw;
17165
4/6
✓ Branch 0 taken 156 times.
✓ Branch 1 taken 105827 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 156 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 156 times.
105983 static ffcdata nil_ffc;
17166
2/2
✓ Branch 0 taken 1981762 times.
✓ Branch 1 taken 105983 times.
2087745 for(word m = 0; m < numffc; ++m)
17167 {
17168
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1981762 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1981762 if(old_ff && !(bits & (1<<m))) continue;
17169
17170
1/2
✓ Branch 0 taken 1981762 times.
✗ Branch 1 not taken.
1981762 ffcdata& tempffc = (m < MAXFFCS)
17171 1981762 ? temp_mapscr->ffcs[m]
17172 : nil_ffc; //sanity
17173
17174
1/2
✓ Branch 0 taken 1981762 times.
✗ Branch 1 not taken.
1981762 if(!p_igetw(&tempw,f))
17175 return qe_invalid;
17176
3/4
✓ Branch 0 taken 1981762 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14345 times.
✓ Branch 3 taken 1967417 times.
1981762 if(!old_ff && !tempw) //empty ffc, nothing more to load
17177 1967417 continue;
17178 14345 tempffc.data = tempw;
17179
17180
1/2
✓ Branch 0 taken 14345 times.
✗ Branch 1 not taken.
14345 if(!p_getc(&(tempffc.cset),f))
17181 return qe_invalid;
17182
1/2
✓ Branch 0 taken 14345 times.
✗ Branch 1 not taken.
14345 if(!p_igetw(&(tempffc.delay),f))
17183 return qe_invalid;
17184
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14345 times.
14345 if(!p_igetzf(&(tempffc.x),f))
17185 return qe_invalid;
17186
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14345 times.
14345 if(!p_igetzf(&(tempffc.y),f))
17187 return qe_invalid;
17188
1/2
✓ Branch 0 taken 14345 times.
✗ Branch 1 not taken.
14345 if(!p_igetzf(&(tempffc.vx),f))
17189 return qe_invalid;
17190
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14345 times.
14345 if(!p_igetzf(&(tempffc.vy),f))
17191 return qe_invalid;
17192
1/2
✓ Branch 0 taken 14345 times.
✗ Branch 1 not taken.
14345 if(!p_igetzf(&(tempffc.ax),f))
17193 return qe_invalid;
17194
1/2
✓ Branch 0 taken 14345 times.
✗ Branch 1 not taken.
14345 if(!p_igetzf(&(tempffc.ay),f))
17195 return qe_invalid;
17196
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14345 times.
14345 if(!p_getc(&(tempffc.link),f))
17197 return qe_invalid;
17198
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14345 times.
14345 if(version < 24)
17199 {
17200 if(!p_getc(&tempbyte,f))
17201 return qe_invalid;
17202 tempffc.hit_width = (tempbyte&0x3F)+1;
17203 tempffc.txsz = (tempbyte>>6)+1;
17204 if(!p_getc(&tempbyte,f))
17205 return qe_invalid;
17206 tempffc.hit_height = (tempbyte&0x3F)+1;
17207 tempffc.tysz = (tempbyte>>6)+1;
17208 }
17209 else
17210 {
17211
1/2
✓ Branch 0 taken 14345 times.
✗ Branch 1 not taken.
14345 if(!p_igetl(&(tempffc.hit_width),f))
17212 return qe_invalid;
17213
1/2
✓ Branch 0 taken 14345 times.
✗ Branch 1 not taken.
14345 if(!p_igetl(&(tempffc.hit_height),f))
17214 return qe_invalid;
17215
1/2
✓ Branch 0 taken 14345 times.
✗ Branch 1 not taken.
14345 if(!p_getc(&(tempffc.txsz),f))
17216 return qe_invalid;
17217
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14345 times.
14345 if(!p_getc(&(tempffc.tysz),f))
17218 return qe_invalid;
17219 }
17220
1/2
✓ Branch 0 taken 14345 times.
✗ Branch 1 not taken.
14345 if(!p_igetl(&(tempffc.flags),f))
17221 return qe_invalid;
17222 14345 tempffc.updateSolid();
17223
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14345 times.
14345 if(!p_igetw(&(tempffc.script),f))
17224 return qe_invalid;
17225
2/2
✓ Branch 0 taken 114760 times.
✓ Branch 1 taken 14345 times.
129105 for(auto q = 0; q < 8; ++q)
17226 {
17227
1/2
✓ Branch 0 taken 114760 times.
✗ Branch 1 not taken.
114760 if(!p_igetl(&(tempffc.initd[q]),f))
17228 return qe_invalid;
17229 114760 }
17230
2/2
✓ Branch 0 taken 8011 times.
✓ Branch 1 taken 6334 times.
14345 if(version < 33)
17231 {
17232
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8011 times.
8011 if(!p_getc(&(tempbyte),f))
17233 return qe_invalid;
17234
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8011 times.
8011 if(!p_getc(&(tempbyte),f))
17235 return qe_invalid;
17236 8011 }
17237
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6334 times.
6334 else if(!p_getc(&(tempffc.layer),f))
17238 return qe_invalid;
17239
17240
1/2
✓ Branch 0 taken 14345 times.
✗ Branch 1 not taken.
14345 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
17241 {
17242 tempffc.script = 0;
17243 for(int q = 0; q < 8; ++q)
17244 tempffc.initd[q] = 0;
17245 }
17246 14345 }
17247 //END FFC
17248
2/2
✓ Branch 0 taken 38497 times.
✓ Branch 1 taken 67486 times.
105983 if(version > 29)
17249
1/2
✓ Branch 0 taken 67486 times.
✗ Branch 1 not taken.
67486 if(!p_getlstr(&temp_mapscr->usr_notes, f))
17250 return qe_invalid;
17251 }
17252
17253 1292455 temp_mapscr->shinkToFitFFCs();
17254
17255 1292455 return 0;
17256 1388840 }
17257
17258 478 int32_t readmaps(PACKFILE *f, zquestheader *Header)
17259 {
17260
2/2
✓ Branch 0 taken 454 times.
✓ Branch 1 taken 24 times.
478 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_maps);
17261 478 int32_t screen=0;
17262
17263 478 word version=0;
17264 dword dummy;
17265 int32_t screens_to_read;
17266
17267 478 mapscr temp_mapscr{};
17268 word temp_map_count;
17269 dword section_size;
17270
17271
5/6
✓ Branch 0 taken 460 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 454 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
478 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
17272 {
17273 18 screens_to_read=MAPSCRS192b136;
17274 18 }
17275 else
17276 {
17277 460 screens_to_read=MAPSCRS;
17278 }
17279
17280
2/2
✓ Branch 0 taken 454 times.
✓ Branch 1 taken 24 times.
478 if(Header->zelda_version > 0x192)
17281 {
17282 //section version info
17283
2/4
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 454 times.
✗ Branch 3 not taken.
454 if(!p_igetw(&version,f))
17284 {
17285 return qe_invalid;
17286 }
17287
17288 454 FFCore.quest_format[vMaps] = version;
17289
17290
2/4
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 454 times.
✗ Branch 3 not taken.
454 if(!p_igetw(&dummy,f))
17291 {
17292 return qe_invalid;
17293 }
17294
17295 //section size
17296
2/4
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 454 times.
✗ Branch 3 not taken.
454 if(!p_igetl(&section_size,f))
17297 {
17298 return qe_invalid;
17299 }
17300
17301 //finally... section data
17302
2/4
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 454 times.
✗ Branch 3 not taken.
454 if(!p_igetw(&temp_map_count,f))
17303 {
17304 return 5;
17305 }
17306 454 }
17307 else
17308 {
17309 24 temp_map_count=map_count;
17310 }
17311
17312
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 478 times.
478 if (temp_map_count > MAXMAPS)
17313 {
17314 return qe_invalid;
17315 }
17316
17317
2/2
✓ Branch 0 taken 477 times.
✓ Branch 1 taken 1 times.
478 if (!should_skip)
17318 {
17319 477 const int32_t _mapsSize = MAPSCRS*temp_map_count;
17320 477 TheMaps.clear();
17321
1/2
✓ Branch 0 taken 477 times.
✗ Branch 1 not taken.
477 TheMaps.resize(_mapsSize);
17322 477 old_combo_pages.clear();
17323
1/2
✓ Branch 0 taken 477 times.
✗ Branch 1 not taken.
477 old_combo_pages.resize(_mapsSize);
17324 477 map_autolayers.clear();
17325
1/2
✓ Branch 0 taken 477 times.
✗ Branch 1 not taken.
477 map_autolayers.resize(temp_map_count*6);
17326
2/2
✓ Branch 0 taken 332 times.
✓ Branch 1 taken 145 times.
477 if(version >= 31)
17327 145 Regions = {};
17328 477 }
17329
17330
4/4
✓ Branch 0 taken 478 times.
✓ Branch 1 taken 10350 times.
✓ Branch 2 taken 10350 times.
✓ Branch 3 taken 478 times.
10828 for(int32_t i=0; i<temp_map_count && i<MAXMAPS; i++)
17331 {
17332 10350 byte valid=1;
17333
2/2
✓ Branch 0 taken 1621 times.
✓ Branch 1 taken 8729 times.
10350 if(version > 22)
17334 {
17335
2/4
✓ Branch 0 taken 1621 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1621 times.
✗ Branch 3 not taken.
1621 if(!p_getc(&valid,f))
17336 return qe_invalid;
17337 1621 }
17338
2/2
✓ Branch 0 taken 133 times.
✓ Branch 1 taken 10217 times.
10350 if(valid)
17339 {
17340
2/2
✓ Branch 0 taken 8859 times.
✓ Branch 1 taken 1358 times.
10217 if (version > 25)
17341 {
17342
2/2
✓ Branch 0 taken 8148 times.
✓ Branch 1 taken 1358 times.
9506 for(int q = 0; q < 6; ++q)
17343 {
17344
2/4
✓ Branch 0 taken 8148 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8148 times.
✗ Branch 3 not taken.
8148 if(!p_igetw(&map_autolayers[i*6+q],f))
17345 return qe_invalid;
17346 8148 }
17347 1358 }
17348
17349
2/2
✓ Branch 0 taken 9301 times.
✓ Branch 1 taken 916 times.
10217 if (version >= 31)
17350 {
17351 static regions_data tmp_rd;
17352
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 916 times.
916 regions_data& rd = should_skip ? tmp_rd : Regions[i];
17353
2/2
✓ Branch 0 taken 7328 times.
✓ Branch 1 taken 916 times.
8244 for(int32_t j=0; j<8; j++)
17354 {
17355
2/2
✓ Branch 0 taken 58624 times.
✓ Branch 1 taken 7328 times.
65952 for(int32_t k=0; k<8; k++)
17356 {
17357
2/4
✓ Branch 0 taken 58624 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58624 times.
✗ Branch 3 not taken.
58624 if(!p_getc(&rd.region_ids[j][k],f))
17358 {
17359 return qe_invalid;
17360 }
17361 58624 }
17362 7328 }
17363 916 }
17364 10217 }
17365
2/2
✓ Branch 0 taken 1406928 times.
✓ Branch 1 taken 10350 times.
1417278 for(int32_t j=0; j<screens_to_read; j++)
17366 {
17367 1406928 screen=i*MAPSCRS+j;
17368
2/2
✓ Branch 0 taken 272 times.
✓ Branch 1 taken 1406656 times.
1406928 mapscr* scr = should_skip ? &temp_mapscr : &TheMaps[screen];
17369 1406928 scr->map = i;
17370 1406928 scr->screen = j;
17371
2/2
✓ Branch 0 taken 1388840 times.
✓ Branch 1 taken 18088 times.
1406928 if(valid)
17372
1/2
✓ Branch 0 taken 1388840 times.
✗ Branch 1 not taken.
1388840 readmapscreen(f, Header, scr, version, screen);
17373
1/2
✓ Branch 0 taken 18088 times.
✗ Branch 1 not taken.
18088 else if (!should_skip)
17374
1/2
✓ Branch 0 taken 18088 times.
✗ Branch 1 not taken.
18088 clear_screen(scr);
17375 1406928 }
17376
17377
2/2
✓ Branch 0 taken 10348 times.
✓ Branch 1 taken 2 times.
10350 if (should_skip)
17378 2 continue;
17379
17380
5/6
✓ Branch 0 taken 10180 times.
✓ Branch 1 taken 168 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 10162 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 18 times.
10348 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
17381 {
17382 168 int32_t index = (i*MAPSCRS+132);
17383
17384
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 TheMaps[index]=TheMaps[index-1];
17385
17386 168 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].data, TheMaps[i*MAPSCRS+131].data);
17387 168 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].sflag, TheMaps[i*MAPSCRS+131].sflag);
17388 168 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].cset, TheMaps[i*MAPSCRS+131].cset);
17389
17390
2/2
✓ Branch 0 taken 504 times.
✓ Branch 1 taken 168 times.
672 for(int32_t j=133; j<MAPSCRS; j++)
17391 {
17392 504 screen=i*MAPSCRS+j;
17393
17394
1/2
✓ Branch 0 taken 504 times.
✗ Branch 1 not taken.
504 TheMaps[screen].zero_memory();
17395 504 TheMaps[screen].valid = mVERSION;
17396 504 TheMaps[screen].screen_midi = -1;
17397 504 TheMaps[screen].csensitive = 1;
17398 504 }
17399 168 }
17400
17401
5/6
✓ Branch 0 taken 10180 times.
✓ Branch 1 taken 168 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 10162 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 18 times.
10348 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
17402 {
17403
2/2
✓ Branch 0 taken 22848 times.
✓ Branch 1 taken 168 times.
23016 for(int32_t j=0; j<MAPSCRS; j++)
17404 {
17405 22848 screen=i*MAPSCRS+j;
17406
1/2
✓ Branch 0 taken 22848 times.
✗ Branch 1 not taken.
22848 TheMaps[screen].door_combo_set=MakeDoors(i, j);
17407
17408
2/2
✓ Branch 0 taken 2924544 times.
✓ Branch 1 taken 22848 times.
2947392 for(int32_t k=0; k<128; k++)
17409 {
17410
1/2
✓ Branch 0 taken 2924544 times.
✗ Branch 1 not taken.
2924544 TheMaps[screen].secretcset[k]=tcmbcset2(i, TheMaps[screen].secretcombo[k]);
17411
1/2
✓ Branch 0 taken 2924544 times.
✗ Branch 1 not taken.
2924544 TheMaps[screen].secretflag[k]=tcmbflag2(i, TheMaps[screen].secretcombo[k]);
17412
1/2
✓ Branch 0 taken 2924544 times.
✗ Branch 1 not taken.
2924544 TheMaps[screen].secretcombo[k]=tcmbdat2(i, j, TheMaps[screen].secretcombo[k]);
17413 2924544 }
17414 22848 }
17415 168 }
17416 10348 }
17417 478 map_count = temp_map_count;
17418 478 return 0;
17419 478 }
17420
17421
17422 9121211 void update_combo(newcombo& cmb, word section_version)
17423 {
17424
2/2
✓ Branch 0 taken 1319665 times.
✓ Branch 1 taken 7801546 times.
9121211 if(section_version < 40)
17425 {
17426
3/3
✓ Branch 0 taken 5168 times.
✓ Branch 1 taken 46100 times.
✓ Branch 2 taken 7750278 times.
7801546 switch(cmb.type)
17427 {
17428 case cWATER: case cSHALLOWWATER:
17429 46100 cmb.attribytes[6] = iwRipples;
17430 46100 break;
17431 case cTALLGRASS: case cTALLGRASSNEXT: case cTALLGRASSTOUCHY:
17432 5168 cmb.attribytes[6] = iwTallGrass;
17433 5168 break;
17434 }
17435 7801546 }
17436
2/2
✓ Branch 0 taken 972234 times.
✓ Branch 1 taken 8148977 times.
9121211 if(section_version < 49)
17437 {
17438
4/4
✓ Branch 0 taken 8113766 times.
✓ Branch 1 taken 35211 times.
✓ Branch 2 taken 15697 times.
✓ Branch 3 taken 8098069 times.
8148977 if(cmb.type == cWATER || cmb.type == cSHALLOWWATER)
17439 50908 cmb.sfx_landing = WAV_ZN1SPLASH;
17440 8148977 }
17441 9121211 }
17442 293 int32_t readcombos_old(word section_version, PACKFILE *f, zquestheader *, word version, word build, word start_combo, word max_combos)
17443 {
17444
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 269 times.
293 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_combos);
17445 byte tempbyte;
17446
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 292 times.
293 if (!should_skip)
17447 {
17448 292 reset_all_combo_animations();
17449 292 init_combo_classes();
17450 292 }
17451
17452 // combos
17453 293 word combos_used=0;
17454 int32_t dummy;
17455 byte padding;
17456 293 newcombo temp_combo;
17457
17458
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 292 times.
293 if (!should_skip)
17459
2/2
✓ Branch 0 taken 19061760 times.
✓ Branch 1 taken 292 times.
19062052 for(int32_t q = start_combo; q < start_combo+max_combos; ++q)
17460
1/2
✓ Branch 0 taken 19061760 times.
✗ Branch 1 not taken.
19062052 combobuf[q].clear();
17461
17462
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 293 times.
293 if(version < 0x174)
17463 {
17464 combos_used=1024;
17465 }
17466
2/2
✓ Branch 0 taken 275 times.
✓ Branch 1 taken 18 times.
293 else if(version < 0x191)
17467 {
17468 18 combos_used=2048;
17469 18 }
17470 else
17471 {
17472
2/4
✓ Branch 0 taken 275 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 275 times.
✗ Branch 3 not taken.
275 if(!p_igetw(&combos_used,f))
17473 {
17474 return qe_invalid;
17475 }
17476 }
17477
17478 //finally... section data
17479
2/2
✓ Branch 0 taken 7666530 times.
✓ Branch 1 taken 293 times.
7666823 for(int32_t i=0; i<combos_used; i++)
17480 {
17481
1/2
✓ Branch 0 taken 7666530 times.
✗ Branch 1 not taken.
7666530 temp_combo.clear();
17482
1/2
✓ Branch 0 taken 7666530 times.
✗ Branch 1 not taken.
7666530 combo_trigger& temp_trigger = temp_combo.triggers.emplace_back();
17483
17484
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7463562 times.
7666530 if ( section_version >= 11 )
17485 {
17486
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetl(&temp_combo.tile,f))
17487 {
17488 return qe_invalid;
17489 }
17490 202968 }
17491 else
17492 {
17493
2/4
✓ Branch 0 taken 7463562 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7463562 times.
✗ Branch 3 not taken.
7463562 if(!p_igetw(&temp_combo.tile,f))
17494 {
17495 return qe_invalid;
17496 }
17497 }
17498 7666530 temp_combo.o_tile = temp_combo.tile;
17499
2/4
✓ Branch 0 taken 7666530 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7666530 times.
✗ Branch 3 not taken.
7666530 if(!p_getc(&temp_combo.flip,f))
17500 {
17501 return qe_invalid;
17502 }
17503
17504
2/4
✓ Branch 0 taken 7666530 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7666530 times.
✗ Branch 3 not taken.
7666530 if(!p_getc(&temp_combo.walk,f))
17505 {
17506 return qe_invalid;
17507 }
17508
17509
2/4
✓ Branch 0 taken 7666530 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7666530 times.
✗ Branch 3 not taken.
7666530 if(!p_getc(&temp_combo.type,f))
17510 {
17511 return qe_invalid;
17512 }
17513
17514
2/4
✓ Branch 0 taken 7666530 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7666530 times.
✗ Branch 3 not taken.
7666530 if(!p_getc(&temp_combo.csets,f))
17515 {
17516 return qe_invalid;
17517 }
17518
17519
2/2
✓ Branch 0 taken 69774 times.
✓ Branch 1 taken 7596756 times.
7666530 if(version < 0x193)
17520 {
17521
2/4
✓ Branch 0 taken 69774 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 69774 times.
✗ Branch 3 not taken.
69774 if(!p_getc(&padding,f))
17522 return qe_invalid;
17523
17524
2/4
✓ Branch 0 taken 69774 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 69774 times.
✗ Branch 3 not taken.
69774 if(!p_getc(&padding,f))
17525 return qe_invalid;
17526
17527
2/2
✓ Branch 0 taken 32910 times.
✓ Branch 1 taken 36864 times.
69774 if(version < 0x192)
17528 {
17529
1/2
✓ Branch 0 taken 36864 times.
✗ Branch 1 not taken.
36864 if(version == 0x191)
17530 {
17531 for(int32_t tmpcounter=0; tmpcounter<16; tmpcounter++)
17532 {
17533 if(!p_getc(&padding,f))
17534 return qe_invalid;
17535 }
17536 }
17537 36864 }
17538 69774 }
17539
2/2
✓ Branch 0 taken 7629666 times.
✓ Branch 1 taken 36864 times.
7666530 if(version >= 0x192)
17540 {
17541
2/4
✓ Branch 0 taken 7629666 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7629666 times.
✗ Branch 3 not taken.
7629666 if(!p_getc(&temp_combo.frames,f))
17542 return qe_invalid;
17543
17544
2/4
✓ Branch 0 taken 7629666 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7629666 times.
✗ Branch 3 not taken.
7629666 if(!p_getc(&temp_combo.speed,f))
17545 return qe_invalid;
17546
17547
2/4
✓ Branch 0 taken 7629666 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7629666 times.
✗ Branch 3 not taken.
7629666 if(!p_igetw(&temp_combo.nextcombo,f))
17548 return qe_invalid;
17549
17550
2/4
✓ Branch 0 taken 7629666 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7629666 times.
✗ Branch 3 not taken.
7629666 if(!p_getc(&temp_combo.nextcset,f))
17551 return qe_invalid;
17552
17553 //Base flag
17554
2/2
✓ Branch 0 taken 4741258 times.
✓ Branch 1 taken 2888408 times.
7629666 if(section_version>=3)
17555
2/4
✓ Branch 0 taken 4741258 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4741258 times.
✗ Branch 3 not taken.
4741258 if(!p_getc(&temp_combo.flag,f))
17556 return qe_invalid;
17557
17558
2/2
✓ Branch 0 taken 4741258 times.
✓ Branch 1 taken 2888408 times.
7629666 if(section_version>=4)
17559 {
17560
2/4
✓ Branch 0 taken 4741258 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4741258 times.
✗ Branch 3 not taken.
4741258 if(!p_getc(&temp_combo.skipanim,f))
17561 return qe_invalid;
17562
17563
2/4
✓ Branch 0 taken 4741258 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4741258 times.
✗ Branch 3 not taken.
4741258 if(!p_igetw(&temp_combo.nexttimer,f))
17564 return qe_invalid;
17565 4741258 }
17566
17567
2/2
✓ Branch 0 taken 4741258 times.
✓ Branch 1 taken 2888408 times.
7629666 if(section_version>=5)
17568
2/4
✓ Branch 0 taken 4741258 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4741258 times.
✗ Branch 3 not taken.
4741258 if(!p_getc(&temp_combo.skipanimy,f))
17569 return qe_invalid;
17570
17571
2/2
✓ Branch 0 taken 4741258 times.
✓ Branch 1 taken 2888408 times.
7629666 if(section_version>=6)
17572 {
17573
2/4
✓ Branch 0 taken 4741258 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4741258 times.
✗ Branch 3 not taken.
4741258 if(!p_getc(&temp_combo.animflags,f))
17574 return qe_invalid;
17575
17576
1/2
✓ Branch 0 taken 4741258 times.
✗ Branch 1 not taken.
4741258 if(section_version == 6)
17577 temp_combo.animflags = temp_combo.animflags ? AF_FRESH : 0;
17578 4741258 }
17579
17580
2/2
✓ Branch 0 taken 7426698 times.
✓ Branch 1 taken 202968 times.
7629666 if(section_version>=8) //combo Attributes[4] and userflags.
17581 {
17582
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 811872 times.
1014840 for ( int32_t q = 0; q < NUM_COMBO_ATTRIBUTES; q++ )
17583
2/4
✓ Branch 0 taken 811872 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 811872 times.
✗ Branch 3 not taken.
811872 if(!p_igetl(&temp_combo.attributes[q],f))
17584 return qe_invalid;
17585
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetl(&temp_combo.usrflags,f))
17586 return qe_invalid;
17587
1/2
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
202968 if(section_version >= 20)
17588
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetw(&temp_combo.genflags,f))
17589 return qe_invalid;
17590 202968 }
17591
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7426698 times.
7629666 if(section_version>=10) //combo trigger flags
17592 {
17593
2/2
✓ Branch 0 taken 608904 times.
✓ Branch 1 taken 202968 times.
811872 for ( int32_t q = 0; q < 3; q++ )
17594
2/4
✓ Branch 0 taken 608904 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 608904 times.
✗ Branch 3 not taken.
608904 if(!p_igetl(&temp_trigger.triggerflags[q],f))
17595 return qe_invalid;
17596 202968 }
17597
1/2
✓ Branch 0 taken 7426698 times.
✗ Branch 1 not taken.
7426698 else if(section_version==9) //combo trigger flags, V9 only had two indices of triggerflags[]
17598 {
17599 for ( int32_t q = 0; q < 2; q++ )
17600 if(!p_igetl(&temp_trigger.triggerflags[q],f))
17601 return qe_invalid;
17602 }
17603
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7426698 times.
7629666 if(section_version >= 9)
17604
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetl(&temp_trigger.triggerlevel,f))
17605 return qe_invalid;
17606
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7426698 times.
7629666 if(section_version >= 22)
17607
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_getc(&temp_trigger.triggerbtn,f))
17608 return qe_invalid;
17609
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7629666 times.
7629666 if(section_version >= 24)
17610 {
17611 if(!p_getc(&temp_trigger.triggeritem,f))
17612 return qe_invalid;
17613 if(!p_getc(&tempbyte, f))
17614 return qe_invalid;
17615 temp_trigger.trigtimer = tempbyte;
17616 }
17617
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7629666 times.
7629666 if(section_version >= 25)
17618 if(!p_getc(&temp_trigger.trigsfx,f))
17619 return qe_invalid;
17620
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7629666 times.
7629666 if(section_version >= 27)
17621 if(!p_igetl(&temp_trigger.trigchange,f))
17622 return qe_invalid;
17623
17624
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7629666 times.
7629666 if(section_version >= 29)
17625 {
17626 if(!p_igetw(&temp_trigger.trigprox,f))
17627 return qe_invalid;
17628 if(!p_getc(&tempbyte,f))
17629 return qe_invalid;
17630 temp_trigger.trigctr = tempbyte;
17631 if(!p_igetl(&temp_trigger.trigctramnt,f))
17632 return qe_invalid;
17633 }
17634
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7629666 times.
7629666 if(section_version >= 30)
17635 if(!p_getc(&temp_trigger.triglbeam,f))
17636 return qe_invalid;
17637
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7629666 times.
7629666 if(section_version >= 31)
17638 {
17639 if(!p_getc(&temp_trigger.trigcschange,f))
17640 return qe_invalid;
17641 if(!p_igetw(&temp_trigger.spawnitem,f))
17642 return qe_invalid;
17643 if(!p_igetw(&temp_trigger.spawnenemy,f))
17644 return qe_invalid;
17645 if(!p_getc(&temp_trigger.exstate,f))
17646 return qe_invalid;
17647 if(!p_igetl(&temp_trigger.spawnip,f))
17648 return qe_invalid;
17649 if(!p_getc(&temp_trigger.trigcopycat,f))
17650 return qe_invalid;
17651 }
17652
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7629666 times.
7629666 if(section_version >= 32)
17653 if(!p_getc(&temp_trigger.trigcooldown,f))
17654 return qe_invalid;
17655
17656
2/2
✓ Branch 0 taken 7426698 times.
✓ Branch 1 taken 202968 times.
7629666 if(section_version>=12) //combo label
17657 {
17658 char label[12];
17659 202968 label[11] = '\0';
17660
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 2232648 times.
2435616 for ( int32_t q = 0; q < 11; q++ )
17661
2/4
✓ Branch 0 taken 2232648 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2232648 times.
✗ Branch 3 not taken.
2232648 if(!p_getc(&label[q],f))
17662 return qe_invalid;
17663
1/2
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
202968 temp_combo.label = label;
17664 202968 }
17665
2/2
✓ Branch 0 taken 7426698 times.
✓ Branch 1 taken 202968 times.
7629666 if(section_version>=13) //attribytes[4]
17666
2/2
✓ Branch 0 taken 811872 times.
✓ Branch 1 taken 202968 times.
1014840 for ( int32_t q = 0; q < 4; q++ )
17667
2/4
✓ Branch 0 taken 811872 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 811872 times.
✗ Branch 3 not taken.
811872 if(!p_getc(&temp_combo.attribytes[q],f))
17668 202968 return qe_invalid;
17669 /* HIGHLY UNORTHODOX UPDATING THING, by Deedee
17670 * This fixes a poor implementation of a ->next flag bug thing.
17671 * Zoria didn't bump up the versions as liberally as he should have, but thankfully
17672 * there was a version bump a few weeks before a change that broke stuff.
17673 */
17674
3/4
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7426698 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 202968 times.
7629666 if (section_version >= 13 && section_version < 21)
17675 {
17676 set_qr(qr_BUGGY_BUGGY_SLASH_TRIGGERS,1);
17677 }
17678 //combo scripts
17679
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7426698 times.
7629666 if(section_version>=14)
17680 {
17681
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetw(&temp_combo.script,f))
17682 return qe_invalid;
17683
2/2
✓ Branch 0 taken 405936 times.
✓ Branch 1 taken 202968 times.
608904 for ( int32_t q = 0; q < 2; q++ )
17684
2/4
✓ Branch 0 taken 405936 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 405936 times.
✗ Branch 3 not taken.
405936 if(!p_igetl(&temp_combo.initd[q],f))
17685 return qe_invalid;
17686 202968 }
17687
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7426698 times.
7629666 if(section_version>=15)
17688 {
17689
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetl(&temp_combo.o_tile,f)) return qe_invalid;
17690
2/2
✓ Branch 0 taken 107633 times.
✓ Branch 1 taken 95335 times.
202968 if(!temp_combo.o_tile) temp_combo.o_tile = temp_combo.tile;
17691
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_getc(&temp_combo.cur_frame,f)) return qe_invalid;
17692
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_getc(&temp_combo.aclk,f)) return qe_invalid;
17693 202968 }
17694
2/2
✓ Branch 0 taken 7426698 times.
✓ Branch 1 taken 202968 times.
7629666 if(section_version>=17) //attribytes[4]
17695 {
17696
2/2
✓ Branch 0 taken 811872 times.
✓ Branch 1 taken 202968 times.
1014840 for ( int32_t q = 4; q < 8; q++ ) //bump up attribytes...
17697
2/4
✓ Branch 0 taken 811872 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 811872 times.
✗ Branch 3 not taken.
811872 if(!p_getc(&temp_combo.attribytes[q],f))
17698 return qe_invalid;
17699
2/2
✓ Branch 0 taken 1623744 times.
✓ Branch 1 taken 202968 times.
1826712 for ( int32_t q = 0; q < 8; q++ ) //...and add attrishorts
17700
2/4
✓ Branch 0 taken 1623744 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1623744 times.
✗ Branch 3 not taken.
1623744 if(!p_igetw(&temp_combo.attrishorts[q],f))
17701 return qe_invalid;
17702 202968 }
17703
17704
2/2
✓ Branch 0 taken 7596756 times.
✓ Branch 1 taken 32910 times.
7629666 if(version < 0x193)
17705
2/2
✓ Branch 0 taken 362010 times.
✓ Branch 1 taken 32910 times.
394920 for(int32_t q=0; q<11; q++)
17706
2/4
✓ Branch 0 taken 362010 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 362010 times.
✗ Branch 3 not taken.
362010 if(!p_getc(&dummy,f))
17707 32910 return qe_invalid;
17708 7629666 }
17709
17710 //Goriya tiles were flipped around in 2.11 build 7. Compensate for the flip here. -DD
17711
3/6
✓ Branch 0 taken 4741258 times.
✓ Branch 1 taken 2925272 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4741258 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7666530 if((version < 0x211)||((version == 0x211)&&(build<7)))
17712 {
17713
2/2
✓ Branch 0 taken 2885336 times.
✓ Branch 1 taken 39936 times.
2925272 if(!get_qr(qr_NEWENEMYTILES))
17714 {
17715
1/5
✓ Branch 0 taken 39936 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
39936 switch(temp_combo.tile)
17716 {
17717 case 130:
17718 temp_combo.tile = 132;
17719 break;
17720
17721 case 131:
17722 temp_combo.tile = 133;
17723 break;
17724
17725 case 132:
17726 temp_combo.tile = 130;
17727 break;
17728
17729 case 133:
17730 temp_combo.tile = 131;
17731 break;
17732 }
17733 39936 }
17734 2925272 }
17735
17736
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7463562 times.
7666530 if(section_version < 15)
17737 7463562 temp_combo.o_tile = temp_combo.tile;
17738
17739
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7463562 times.
7666530 if(section_version<18) //upper bits for .walk
17740 7463562 temp_combo.walk |= 0xF0;
17741
17742
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7463562 times.
7666530 if(section_version < 19)
17743
2/2
✓ Branch 0 taken 29854248 times.
✓ Branch 1 taken 7463562 times.
37317810 for(int32_t q = 0; q < 4; ++q)
17744 37317810 temp_combo.attributes[q] *= 10000L;
17745
17746
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7666530 times.
7666530 if(section_version < 23)
17747 {
17748
2/2
✓ Branch 0 taken 15359 times.
✓ Branch 1 taken 7651171 times.
7666530 switch(temp_combo.type) //combotriggerCMBTYPEFX now required for combotype-specific effects
17749 {
17750 case cSCRIPT1: case cSCRIPT2: case cSCRIPT3: case cSCRIPT4: case cSCRIPT5:
17751 case cSCRIPT6: case cSCRIPT7: case cSCRIPT8: case cSCRIPT9: case cSCRIPT10:
17752 case cTRIGGERGENERIC: case cCSWITCH:
17753 15359 temp_trigger.triggerflags[0] |= combotriggerCMBTYPEFX;
17754 15359 }
17755 7666530 }
17756
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7666530 times.
7666530 if(section_version < 25)
17757 {
17758
2/2
✓ Branch 0 taken 27600 times.
✓ Branch 1 taken 7638930 times.
7666530 switch(temp_combo.type)
17759 {
17760 case cLOCKBLOCK: case cBOSSLOCKBLOCK:
17761
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27600 times.
27600 if(!(temp_combo.usrflags & cflag3))
17762 27600 temp_combo.attribytes[3] = WAV_DOOR;
17763 27600 temp_combo.usrflags &= ~cflag3;
17764 27600 break;
17765 }
17766 7666530 }
17767
17768
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7666530 times.
7666530 if(section_version < 26)
17769
2/2
✓ Branch 0 taken 7665388 times.
✓ Branch 1 taken 1142 times.
7667672 if(temp_combo.type == cARMOS)
17770
1/2
✓ Branch 0 taken 1142 times.
✗ Branch 1 not taken.
1142 if(temp_combo.usrflags & cflag1)
17771 temp_combo.usrflags |= cflag3;
17772
17773
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7666530 times.
7666530 if(section_version < 27)
17774 {
17775
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7666530 times.
7666530 if(temp_trigger.triggerflags[0] & 0x00040000) //'next'
17776 temp_trigger.trigchange = 1;
17777
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7666530 times.
7666530 else if(temp_trigger.triggerflags[0] & 0x00080000) //'prev'
17778 temp_trigger.trigchange = -1;
17779 7666530 else temp_trigger.trigchange = 0;
17780 7666530 temp_trigger.triggerflags[0] &= ~(0x00040000|0x00080000);
17781 7666530 }
17782
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7666530 times.
7666530 if(section_version < 28)
17783 {
17784
2/2
✓ Branch 0 taken 15669 times.
✓ Branch 1 taken 7650861 times.
7666530 switch(temp_combo.type)
17785 {
17786 case cLOCKBLOCK: case cLOCKEDCHEST:
17787
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15669 times.
15669 if(temp_combo.usrflags & cflag7)
17788 temp_combo.usrflags |= cflag8;
17789 15669 else temp_combo.usrflags &= ~cflag8;
17790 15669 temp_combo.usrflags &= ~cflag7;
17791 15669 break;
17792 }
17793
2/2
✓ Branch 0 taken 782 times.
✓ Branch 1 taken 7665748 times.
7666530 switch(temp_combo.type)
17794 {
17795 case cCHEST: case cLOCKEDCHEST: case cBOSSCHEST:
17796 782 temp_combo.attrishorts[2] = -1;
17797 782 temp_combo.usrflags |= cflag7;
17798 782 break;
17799 }
17800 7666530 }
17801
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7463562 times.
7666530 if(section_version < 20)
17802 {
17803 7463562 temp_combo.genflags = 0;
17804
2/2
✓ Branch 0 taken 144654 times.
✓ Branch 1 taken 7318908 times.
7463562 switch(temp_combo.type)
17805 {
17806 case cPUSH_WAIT: case cPUSH_HEAVY:
17807 case cPUSH_HW: case cL_STATUE:
17808 case cR_STATUE: case cPUSH_HEAVY2:
17809 case cPUSH_HW2: case cPOUND:
17810 case cC_STATUE: case cMIRROR:
17811 case cMIRRORSLASH: case cMIRRORBACKSLASH:
17812 case cMAGICPRISM: case cMAGICPRISM4:
17813 case cMAGICSPONGE: case cEYEBALL_A:
17814 case cEYEBALL_B: case cEYEBALL_4:
17815 case cBUSH: case cFLOWERS:
17816 case cLOCKBLOCK: case cLOCKBLOCK2:
17817 case cBOSSLOCKBLOCK: case cBOSSLOCKBLOCK2:
17818 case cCHEST: case cCHEST2:
17819 case cLOCKEDCHEST: case cLOCKEDCHEST2:
17820 case cBOSSCHEST: case cBOSSCHEST2:
17821 case cBUSHNEXT: case cBUSHTOUCHY:
17822 case cFLOWERSTOUCHY: case cBUSHNEXTTOUCHY:
17823 case cSIGNPOST: case cCSWITCHBLOCK:
17824 case cTORCH: case cTRIGGERGENERIC:
17825
1/2
✓ Branch 0 taken 144654 times.
✗ Branch 1 not taken.
144654 if(temp_combo.usrflags & cflag16)
17826 {
17827 temp_combo.genflags |= cflag1;
17828 temp_combo.usrflags &= ~cflag16;
17829 }
17830 144654 break;
17831 }
17832 7463562 }
17833
17834
3/4
✓ Branch 0 taken 7666530 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15398 times.
✓ Branch 3 taken 7651132 times.
7666530 if(temp_trigger.is_blank())
17835 7651132 temp_combo.triggers.clear();
17836
17837 7666530 update_combo(temp_combo, section_version);
17838
17839
3/4
✓ Branch 0 taken 7666530 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7651611 times.
✓ Branch 3 taken 14919 times.
7666530 if(i>=start_combo && !should_skip)
17840 {
17841
1/2
✓ Branch 0 taken 7651611 times.
✗ Branch 1 not taken.
7651611 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
17842 {
17843 temp_combo.script = 0;
17844 for(int q = 0; q < 8; ++q)
17845 temp_combo.initd[q] = 0;
17846 }
17847
1/2
✓ Branch 0 taken 7651611 times.
✗ Branch 1 not taken.
7651611 combobuf[i] = temp_combo;
17848 7651611 }
17849 7666530 }
17850
17851
2/2
✓ Branch 0 taken 292 times.
✓ Branch 1 taken 1 times.
293 if (should_skip)
17852 1 return 0;
17853
17854
5/6
✓ Branch 0 taken 274 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 269 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
292 if((version < 0x192)|| ((version == 0x192)&&(build<185)))
17855 {
17856
2/2
✓ Branch 0 taken 1501440 times.
✓ Branch 1 taken 23 times.
1501463 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
17857 {
17858
2/2
✓ Branch 0 taken 1501225 times.
✓ Branch 1 taken 215 times.
1501440 if(combobuf[tmpcounter].type==cHOOKSHOTONLY)
17859 {
17860 215 combobuf[tmpcounter].type=cLADDERHOOKSHOT;
17861 215 }
17862 1501440 }
17863 23 }
17864
17865 //June 3 2012; ladder only is broken in 2.10 and allows the hookshot also. -Gleeok
17866
4/6
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 233 times.
✓ Branch 2 taken 59 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 59 times.
292 if(version == 0x210 && get_app_id() != App::zquest)
17867 {
17868
2/2
✓ Branch 0 taken 3851520 times.
✓ Branch 1 taken 59 times.
3851579 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
17869
2/2
✓ Branch 0 taken 3851335 times.
✓ Branch 1 taken 185 times.
3851705 if(combobuf[tmpcounter].type == cLADDERONLY)
17870 185 combobuf[tmpcounter].type = cLADDERHOOKSHOT;
17871 59 }
17872
17873
2/2
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 82 times.
292 if(section_version<7)
17874 {
17875
2/2
✓ Branch 0 taken 5352960 times.
✓ Branch 1 taken 82 times.
5353042 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
17876 {
17877
6/9
✓ Branch 0 taken 5350008 times.
✓ Branch 1 taken 853 times.
✓ Branch 2 taken 791 times.
✓ Branch 3 taken 603 times.
✓ Branch 4 taken 174 times.
✓ Branch 5 taken 531 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
5352960 switch(combobuf[tmpcounter].type)
17878 {
17879 case cSLASH:
17880 853 combobuf[tmpcounter].type=cSLASHTOUCHY;
17881 853 break;
17882
17883 case cSLASHITEM:
17884 791 combobuf[tmpcounter].type=cSLASHITEMTOUCHY;
17885 791 break;
17886
17887 case cBUSH:
17888 603 combobuf[tmpcounter].type=cBUSHTOUCHY;
17889 603 break;
17890
17891 case cFLOWERS:
17892 174 combobuf[tmpcounter].type=cFLOWERSTOUCHY;
17893 174 break;
17894
17895 case cTALLGRASS:
17896 531 combobuf[tmpcounter].type=cTALLGRASSTOUCHY;
17897 531 break;
17898
17899 case cSLASHNEXT:
17900 combobuf[tmpcounter].type=cSLASHNEXTTOUCHY;
17901 break;
17902
17903 case cSLASHNEXTITEM:
17904 combobuf[tmpcounter].type=cSLASHNEXTITEMTOUCHY;
17905 break;
17906
17907 case cBUSHNEXT:
17908 combobuf[tmpcounter].type=cBUSHNEXTTOUCHY;
17909 break;
17910 }
17911 5352960 }
17912 82 }
17913
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 287 times.
292 if (section_version < 16)
17914 {
17915
2/2
✓ Branch 0 taken 18735360 times.
✓ Branch 1 taken 287 times.
18735647 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
17916 {
17917
2/2
✓ Branch 0 taken 18706079 times.
✓ Branch 1 taken 29281 times.
18735360 if (combobuf[tmpcounter].type == cWATER)
17918 {
17919 29281 combobuf[tmpcounter].attributes[0] = 40000L;
17920 29281 }
17921 18735360 }
17922 287 }
17923
2/2
✓ Branch 0 taken 289 times.
✓ Branch 1 taken 3 times.
292 if(!get_qr(qr_ALLOW_EDITING_COMBO_0))
17924 {
17925 3 combobuf[0].walk = 0xF0;
17926 3 combobuf[0].type = 0;
17927 3 combobuf[0].flag = 0;
17928 3 }
17929
17930 //Now for the new combo alias reset
17931
2/2
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 82 times.
292 if(section_version<2)
17932 {
17933
2/2
✓ Branch 0 taken 671744 times.
✓ Branch 1 taken 82 times.
671826 for(int32_t j=0; j<MAXCOMBOALIASES; j++)
17934 {
17935 671744 combo_aliases[j].width = 0;
17936 671744 combo_aliases[j].height = 0;
17937 671744 combo_aliases[j].layermask = 0;
17938
1/2
✓ Branch 0 taken 671744 times.
✗ Branch 1 not taken.
671744 combo_aliases[j].combos.clear();
17939
1/2
✓ Branch 0 taken 671744 times.
✗ Branch 1 not taken.
671744 combo_aliases[j].csets.clear();
17940 671744 }
17941 82 }
17942
17943
17944
1/2
✓ Branch 0 taken 292 times.
✗ Branch 1 not taken.
292 setup_combo_animations();
17945
1/2
✓ Branch 0 taken 292 times.
✗ Branch 1 not taken.
292 setup_combo_animations2();
17946 292 return 0;
17947 293 }
17948
17949 12591 int32_t readcombo_triggers_loop(PACKFILE* f, word s_version, combo_trigger& temp_trigger)
17950 {
17951 byte tempbyte;
17952
2/2
✓ Branch 0 taken 7621 times.
✓ Branch 1 taken 4970 times.
12591 if(s_version >= 52)
17953
1/2
✓ Branch 0 taken 4970 times.
✗ Branch 1 not taken.
4970 if(!p_getcstr(&temp_trigger.label,f))
17954 return qe_invalid;
17955
17956 12591 int numtrigs = s_version < 36 ? 3 : 6;
17957
2/2
✓ Branch 0 taken 74688 times.
✓ Branch 1 taken 12591 times.
87279 for ( int32_t q = 0; q < numtrigs; q++ )
17958
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74688 times.
74688 if(!p_igetl(&temp_trigger.triggerflags[q],f))
17959 return qe_invalid;
17960
1/2
✓ Branch 0 taken 12591 times.
✗ Branch 1 not taken.
12591 if(!p_igetl(&temp_trigger.triggerlevel,f))
17961 return qe_invalid;
17962
1/2
✓ Branch 0 taken 12591 times.
✗ Branch 1 not taken.
12591 if(!p_getc(&temp_trigger.triggerbtn,f))
17963 return qe_invalid;
17964
1/2
✓ Branch 0 taken 12591 times.
✗ Branch 1 not taken.
12591 if(!p_getc(&temp_trigger.triggeritem,f))
17965 return qe_invalid;
17966
2/2
✓ Branch 0 taken 4970 times.
✓ Branch 1 taken 7621 times.
12591 if(s_version >= 53)
17967 {
17968
1/2
✓ Branch 0 taken 4970 times.
✗ Branch 1 not taken.
4970 if(!p_igetw(&temp_trigger.trigtimer,f))
17969 return qe_invalid;
17970 4970 }
17971 else
17972 {
17973
1/2
✓ Branch 0 taken 7621 times.
✗ Branch 1 not taken.
7621 if(!p_getc(&tempbyte, f))
17974 return qe_invalid;
17975 7621 temp_trigger.trigtimer = tempbyte;
17976 }
17977
1/2
✓ Branch 0 taken 12591 times.
✗ Branch 1 not taken.
12591 if(!p_getc(&temp_trigger.trigsfx,f))
17978 return qe_invalid;
17979
1/2
✓ Branch 0 taken 12591 times.
✗ Branch 1 not taken.
12591 if(!p_igetl(&temp_trigger.trigchange,f))
17980 return qe_invalid;
17981
1/2
✓ Branch 0 taken 12591 times.
✗ Branch 1 not taken.
12591 if(!p_igetw(&temp_trigger.trigprox,f))
17982 return qe_invalid;
17983
2/2
✓ Branch 0 taken 4970 times.
✓ Branch 1 taken 7621 times.
12591 if(s_version >= 53)
17984 {
17985
1/2
✓ Branch 0 taken 4970 times.
✗ Branch 1 not taken.
4970 if(!p_igetw(&temp_trigger.trigctr,f))
17986 return qe_invalid;
17987 4970 }
17988 else
17989 {
17990
1/2
✓ Branch 0 taken 7621 times.
✗ Branch 1 not taken.
7621 if(!p_getc(&tempbyte,f))
17991 return qe_invalid;
17992 7621 temp_trigger.trigctr = tempbyte;
17993 }
17994
1/2
✓ Branch 0 taken 12591 times.
✗ Branch 1 not taken.
12591 if(!p_igetl(&temp_trigger.trigctramnt,f))
17995 return qe_invalid;
17996
1/2
✓ Branch 0 taken 12591 times.
✗ Branch 1 not taken.
12591 if(!p_getc(&temp_trigger.triglbeam,f))
17997 return qe_invalid;
17998
1/2
✓ Branch 0 taken 12591 times.
✗ Branch 1 not taken.
12591 if(!p_getc(&temp_trigger.trigcschange,f))
17999 return qe_invalid;
18000
1/2
✓ Branch 0 taken 12591 times.
✗ Branch 1 not taken.
12591 if(!p_igetw(&temp_trigger.spawnitem,f))
18001 return qe_invalid;
18002
1/2
✓ Branch 0 taken 12591 times.
✗ Branch 1 not taken.
12591 if(!p_igetw(&temp_trigger.spawnenemy,f))
18003 return qe_invalid;
18004
1/2
✓ Branch 0 taken 12591 times.
✗ Branch 1 not taken.
12591 if(!p_getc(&temp_trigger.exstate,f))
18005 return qe_invalid;
18006
1/2
✓ Branch 0 taken 12591 times.
✗ Branch 1 not taken.
12591 if(!p_igetl(&temp_trigger.spawnip,f))
18007 return qe_invalid;
18008
1/2
✓ Branch 0 taken 12591 times.
✗ Branch 1 not taken.
12591 if(!p_getc(&temp_trigger.trigcopycat,f))
18009 return qe_invalid;
18010
1/2
✓ Branch 0 taken 12591 times.
✗ Branch 1 not taken.
12591 if(!p_getc(&temp_trigger.trigcooldown,f))
18011 return qe_invalid;
18012
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12591 times.
12591 if(s_version >= 35)
18013 {
18014
1/2
✓ Branch 0 taken 12591 times.
✗ Branch 1 not taken.
12591 if(!p_igetw(&temp_trigger.prompt_cid,f))
18015 return qe_invalid;
18016
1/2
✓ Branch 0 taken 12591 times.
✗ Branch 1 not taken.
12591 if(!p_getc(&temp_trigger.prompt_cs,f))
18017 return qe_invalid;
18018
1/2
✓ Branch 0 taken 12591 times.
✗ Branch 1 not taken.
12591 if(!p_igetw(&temp_trigger.prompt_x,f))
18019 return qe_invalid;
18020
1/2
✓ Branch 0 taken 12591 times.
✗ Branch 1 not taken.
12591 if(!p_igetw(&temp_trigger.prompt_y,f))
18021 return qe_invalid;
18022 12591 }
18023
2/2
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 12305 times.
12591 if(s_version >= 36)
18024 {
18025
1/2
✓ Branch 0 taken 12305 times.
✗ Branch 1 not taken.
12305 if(!p_getc(&temp_trigger.trig_lstate,f))
18026 return qe_invalid;
18027
1/2
✓ Branch 0 taken 12305 times.
✗ Branch 1 not taken.
12305 if(!p_getc(&temp_trigger.trig_gstate,f))
18028 return qe_invalid;
18029
1/2
✓ Branch 0 taken 12305 times.
✗ Branch 1 not taken.
12305 if(!p_igetl(&temp_trigger.trig_statetime,f))
18030 return qe_invalid;
18031 12305 }
18032
2/2
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 12305 times.
12591 if(s_version >= 37)
18033 {
18034
1/2
✓ Branch 0 taken 12305 times.
✗ Branch 1 not taken.
12305 if(!p_igetw(&temp_trigger.trig_genscr,f))
18035 return qe_invalid;
18036 12305 }
18037
2/2
✓ Branch 0 taken 434 times.
✓ Branch 1 taken 12157 times.
12591 if(s_version >= 38)
18038 {
18039
1/2
✓ Branch 0 taken 12157 times.
✗ Branch 1 not taken.
12157 if(!p_getc(&temp_trigger.trig_group,f))
18040 return qe_invalid;
18041
1/2
✓ Branch 0 taken 12157 times.
✗ Branch 1 not taken.
12157 if(!p_igetw(&temp_trigger.trig_group_val,f))
18042 return qe_invalid;
18043 12157 }
18044
2/2
✓ Branch 0 taken 470 times.
✓ Branch 1 taken 12121 times.
12591 if(s_version >= 45)
18045 {
18046
1/2
✓ Branch 0 taken 12121 times.
✗ Branch 1 not taken.
12121 if(!p_getc(&temp_trigger.exdoor_dir,f))
18047 return qe_invalid;
18048
1/2
✓ Branch 0 taken 12121 times.
✗ Branch 1 not taken.
12121 if(!p_getc(&temp_trigger.exdoor_ind,f))
18049 return qe_invalid;
18050 12121 }
18051
2/2
✓ Branch 0 taken 7112 times.
✓ Branch 1 taken 5479 times.
12591 if(s_version >= 46)
18052 {
18053
1/2
✓ Branch 0 taken 5479 times.
✗ Branch 1 not taken.
5479 if(!p_getc(&temp_trigger.trig_levelitems,f))
18054 return qe_invalid;
18055
1/2
✓ Branch 0 taken 5479 times.
✗ Branch 1 not taken.
5479 if(!p_igetw(&temp_trigger.trigdmlevel,f))
18056 return qe_invalid;
18057
1/2
✓ Branch 0 taken 5479 times.
✗ Branch 1 not taken.
5479 if(s_version >= 48)
18058 {
18059
2/2
✓ Branch 0 taken 16437 times.
✓ Branch 1 taken 5479 times.
21916 for(int q = 0; q < 3; ++q)
18060
1/2
✓ Branch 0 taken 16437 times.
✗ Branch 1 not taken.
16437 if(!p_igetw(&temp_trigger.trigtint[q],f))
18061 return qe_invalid;
18062 5479 }
18063 else
18064 {
18065 for(int q = 0; q < 3; ++q)
18066 if(!p_getc(&temp_trigger.trigtint[q],f))
18067 return qe_invalid;
18068 for(int q = 0; q < 3; ++q)
18069 {
18070 int v = temp_trigger.trigtint[q];
18071 int va = abs(v);
18072 temp_trigger.trigtint[q] = _rgb_scale_6[va] * sign(v);
18073 }
18074 }
18075
1/2
✓ Branch 0 taken 5479 times.
✗ Branch 1 not taken.
5479 if(!p_igetw(&temp_trigger.triglvlpalette,f))
18076 return qe_invalid;
18077
1/2
✓ Branch 0 taken 5479 times.
✗ Branch 1 not taken.
5479 if(!p_igetw(&temp_trigger.trigbosspalette,f))
18078 return qe_invalid;
18079
1/2
✓ Branch 0 taken 5479 times.
✗ Branch 1 not taken.
5479 if(!p_igetw(&temp_trigger.trigquaketime,f))
18080 return qe_invalid;
18081
1/2
✓ Branch 0 taken 5479 times.
✗ Branch 1 not taken.
5479 if(!p_igetw(&temp_trigger.trigwavytime,f))
18082 return qe_invalid;
18083
1/2
✓ Branch 0 taken 5479 times.
✗ Branch 1 not taken.
5479 if(!p_igetw(&temp_trigger.trig_swjinxtime,f))
18084 return qe_invalid;
18085
1/2
✓ Branch 0 taken 5479 times.
✗ Branch 1 not taken.
5479 if(!p_igetw(&temp_trigger.trig_itmjinxtime,f))
18086 return qe_invalid;
18087
1/2
✓ Branch 0 taken 5479 times.
✗ Branch 1 not taken.
5479 if(!p_igetw(&temp_trigger.trig_stuntime,f))
18088 return qe_invalid;
18089
1/2
✓ Branch 0 taken 5479 times.
✗ Branch 1 not taken.
5479 if(!p_igetw(&temp_trigger.trig_bunnytime,f))
18090 return qe_invalid;
18091
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5479 times.
5479 if(!p_getc(&temp_trigger.trig_pushtime,f))
18092 return qe_invalid;
18093 5479 }
18094
2/2
✓ Branch 0 taken 7112 times.
✓ Branch 1 taken 5479 times.
12591 if(s_version >= 47)
18095 {
18096
1/2
✓ Branch 0 taken 5479 times.
✗ Branch 1 not taken.
5479 if (!p_igetw(&temp_trigger.trig_shieldjinxtime, f))
18097 return qe_invalid;
18098 5479 }
18099
2/2
✓ Branch 0 taken 4970 times.
✓ Branch 1 taken 7621 times.
12591 if(s_version >= 53)
18100 {
18101
1/2
✓ Branch 0 taken 4970 times.
✗ Branch 1 not taken.
4970 if(!p_igetl(&temp_trigger.req_level_state, f))
18102 return qe_invalid;
18103
1/2
✓ Branch 0 taken 4970 times.
✗ Branch 1 not taken.
4970 if(!p_igetl(&temp_trigger.unreq_level_state, f))
18104 return qe_invalid;
18105
1/2
✓ Branch 0 taken 4970 times.
✗ Branch 1 not taken.
4970 if(!p_getbitstr(&temp_trigger.req_global_state, f))
18106 return qe_invalid;
18107
1/2
✓ Branch 0 taken 4970 times.
✗ Branch 1 not taken.
4970 if(!p_getbitstr(&temp_trigger.unreq_global_state, f))
18108 return qe_invalid;
18109
1/2
✓ Branch 0 taken 4970 times.
✗ Branch 1 not taken.
4970 if(!p_igetw(&temp_trigger.fail_prompt_cid,f))
18110 return qe_invalid;
18111
1/2
✓ Branch 0 taken 4970 times.
✗ Branch 1 not taken.
4970 if(!p_getc(&temp_trigger.fail_prompt_cs,f))
18112 return qe_invalid;
18113
1/2
✓ Branch 0 taken 4970 times.
✗ Branch 1 not taken.
4970 if(!p_igetl(&temp_trigger.trig_msgstr, f))
18114 return qe_invalid;
18115
1/2
✓ Branch 0 taken 4970 times.
✗ Branch 1 not taken.
4970 if(!p_igetl(&temp_trigger.fail_msgstr, f))
18116 return qe_invalid;
18117
1/2
✓ Branch 0 taken 4970 times.
✗ Branch 1 not taken.
4970 if(!p_igetzf(&temp_trigger.player_bounce, f))
18118 return qe_invalid;
18119
1/2
✓ Branch 0 taken 4970 times.
✗ Branch 1 not taken.
4970 if(!p_igetzf(&temp_trigger.req_player_z, f))
18120 return qe_invalid;
18121 4970 }
18122 else
18123 {
18124 7621 temp_trigger.fail_prompt_cid = temp_trigger.prompt_cid;
18125 7621 temp_trigger.fail_prompt_cs = temp_trigger.prompt_cs;
18126 }
18127
2/2
✓ Branch 0 taken 7867 times.
✓ Branch 1 taken 4724 times.
12591 if(s_version >= 54)
18128 {
18129
1/2
✓ Branch 0 taken 4724 times.
✗ Branch 1 not taken.
4724 if(!p_getc(&temp_trigger.req_player_dir,f))
18130 return qe_invalid;
18131
1/2
✓ Branch 0 taken 4724 times.
✗ Branch 1 not taken.
4724 if(!p_igetzf(&temp_trigger.dest_player_x, f))
18132 return qe_invalid;
18133
1/2
✓ Branch 0 taken 4724 times.
✗ Branch 1 not taken.
4724 if(!p_igetzf(&temp_trigger.dest_player_y, f))
18134 return qe_invalid;
18135
1/2
✓ Branch 0 taken 4724 times.
✗ Branch 1 not taken.
4724 if(!p_igetzf(&temp_trigger.dest_player_z, f))
18136 return qe_invalid;
18137
1/2
✓ Branch 0 taken 4724 times.
✗ Branch 1 not taken.
4724 if(!p_igetzf(&temp_trigger.req_player_jump, f))
18138 return qe_invalid;
18139
1/2
✓ Branch 0 taken 4724 times.
✗ Branch 1 not taken.
4724 if(!p_igetzf(&temp_trigger.req_player_x, f))
18140 return qe_invalid;
18141
1/2
✓ Branch 0 taken 4724 times.
✗ Branch 1 not taken.
4724 if(!p_igetzf(&temp_trigger.req_player_y, f))
18142 return qe_invalid;
18143 4724 }
18144 12591 return 0;
18145 12591 }
18146
18147 1454681 int32_t readcombo_loop(PACKFILE* f, word s_version, newcombo& temp_combo)
18148 {
18149 byte combo_has_flags;
18150
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1454681 times.
1454681 if(!p_getc(&combo_has_flags,f))
18151 return qe_invalid;
18152
18153 1454681 temp_combo.clear();
18154
2/2
✓ Branch 0 taken 798727 times.
✓ Branch 1 taken 655954 times.
1454681 if(combo_has_flags)
18155 {
18156
2/2
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 655897 times.
655954 if(combo_has_flags&CHAS_BASIC)
18157 {
18158
1/2
✓ Branch 0 taken 655897 times.
✗ Branch 1 not taken.
655897 if(!p_igetl(&temp_combo.tile,f))
18159 return qe_invalid;
18160 655897 temp_combo.o_tile = temp_combo.tile;
18161
18162
1/2
✓ Branch 0 taken 655897 times.
✗ Branch 1 not taken.
655897 if(!p_getc(&temp_combo.flip,f))
18163 return qe_invalid;
18164
18165
1/2
✓ Branch 0 taken 655897 times.
✗ Branch 1 not taken.
655897 if(!p_getc(&temp_combo.walk,f))
18166 return qe_invalid;
18167
18168
1/2
✓ Branch 0 taken 655897 times.
✗ Branch 1 not taken.
655897 if(!p_getc(&temp_combo.type,f))
18169 return qe_invalid;
18170
18171
1/2
✓ Branch 0 taken 655897 times.
✗ Branch 1 not taken.
655897 if(!p_getc(&temp_combo.flag,f))
18172 return qe_invalid;
18173
18174
1/2
✓ Branch 0 taken 655897 times.
✗ Branch 1 not taken.
655897 if(!p_getc(&temp_combo.csets,f))
18175 return qe_invalid;
18176 655897 }
18177
2/2
✓ Branch 0 taken 653099 times.
✓ Branch 1 taken 2855 times.
655954 if(combo_has_flags&CHAS_SCRIPT)
18178 {
18179
2/2
✓ Branch 0 taken 2825 times.
✓ Branch 1 taken 30 times.
2855 if (s_version>=41)
18180 {
18181 2825 p_getcstr(&temp_combo.label, f);
18182 2825 }
18183 else
18184 {
18185 char label[12];
18186 30 label[11] = '\0';
18187
2/2
✓ Branch 0 taken 330 times.
✓ Branch 1 taken 30 times.
360 for ( int32_t q = 0; q < 11; q++ )
18188
1/2
✓ Branch 0 taken 330 times.
✗ Branch 1 not taken.
330 if(!p_getc(&label[q],f))
18189 return qe_invalid;
18190 30 temp_combo.label = label;
18191 }
18192
18193
1/2
✓ Branch 0 taken 2855 times.
✗ Branch 1 not taken.
2855 if(!p_igetw(&temp_combo.script,f)) return qe_invalid;
18194 2855 auto initd_count = s_version >= 43 ? 8 : 2;
18195
2/2
✓ Branch 0 taken 22660 times.
✓ Branch 1 taken 2855 times.
25515 for ( int32_t q = 0; q < initd_count; q++ )
18196
1/2
✓ Branch 0 taken 22660 times.
✗ Branch 1 not taken.
22660 if(!p_igetl(&temp_combo.initd[q],f))
18197 return qe_invalid;
18198 2855 }
18199
2/2
✓ Branch 0 taken 530732 times.
✓ Branch 1 taken 125222 times.
655954 if(combo_has_flags&CHAS_ANIM)
18200 {
18201
1/2
✓ Branch 0 taken 125222 times.
✗ Branch 1 not taken.
125222 if(!p_getc(&temp_combo.frames,f))
18202 return qe_invalid;
18203
18204
1/2
✓ Branch 0 taken 125222 times.
✗ Branch 1 not taken.
125222 if(!p_getc(&temp_combo.speed,f))
18205 return qe_invalid;
18206
18207
1/2
✓ Branch 0 taken 125222 times.
✗ Branch 1 not taken.
125222 if(!p_igetw(&temp_combo.nextcombo,f))
18208 return qe_invalid;
18209
18210
1/2
✓ Branch 0 taken 125222 times.
✗ Branch 1 not taken.
125222 if(!p_getc(&temp_combo.nextcset,f))
18211 return qe_invalid;
18212
18213
1/2
✓ Branch 0 taken 125222 times.
✗ Branch 1 not taken.
125222 if(!p_getc(&temp_combo.skipanim,f))
18214 return qe_invalid;
18215
18216
1/2
✓ Branch 0 taken 125222 times.
✗ Branch 1 not taken.
125222 if(!p_getc(&temp_combo.skipanimy,f))
18217 return qe_invalid;
18218
18219
1/2
✓ Branch 0 taken 125222 times.
✗ Branch 1 not taken.
125222 if(!p_getc(&temp_combo.animflags,f))
18220 return qe_invalid;
18221 125222 }
18222
2/2
✓ Branch 0 taken 600838 times.
✓ Branch 1 taken 55116 times.
655954 if(combo_has_flags&CHAS_ATTRIB)
18223 {
18224
2/2
✓ Branch 0 taken 220464 times.
✓ Branch 1 taken 55116 times.
275580 for ( int32_t q = 0; q < 4; q++ )
18225
1/2
✓ Branch 0 taken 220464 times.
✗ Branch 1 not taken.
220464 if(!p_igetl(&temp_combo.attributes[q],f))
18226 return qe_invalid;
18227
2/2
✓ Branch 0 taken 440928 times.
✓ Branch 1 taken 55116 times.
496044 for ( int32_t q = 0; q < 8; q++ )
18228
1/2
✓ Branch 0 taken 440928 times.
✗ Branch 1 not taken.
440928 if(!p_getc(&temp_combo.attribytes[q],f))
18229 return qe_invalid;
18230
2/2
✓ Branch 0 taken 440928 times.
✓ Branch 1 taken 55116 times.
496044 for ( int32_t q = 0; q < 8; q++ )
18231
1/2
✓ Branch 0 taken 440928 times.
✗ Branch 1 not taken.
440928 if(!p_igetw(&temp_combo.attrishorts[q],f))
18232 return qe_invalid;
18233 55116 }
18234
2/2
✓ Branch 0 taken 644042 times.
✓ Branch 1 taken 11912 times.
655954 if(combo_has_flags&CHAS_FLAG)
18235 {
18236
1/2
✓ Branch 0 taken 11912 times.
✗ Branch 1 not taken.
11912 if(!p_igetl(&temp_combo.usrflags,f))
18237 return qe_invalid;
18238
1/2
✓ Branch 0 taken 11912 times.
✗ Branch 1 not taken.
11912 if(!p_igetw(&temp_combo.genflags,f))
18239 return qe_invalid;
18240 11912 }
18241
2/2
✓ Branch 0 taken 643426 times.
✓ Branch 1 taken 12528 times.
655954 if(combo_has_flags&CHAS_TRIG)
18242 {
18243 12528 byte count = 1;
18244
2/2
✓ Branch 0 taken 7621 times.
✓ Branch 1 taken 4907 times.
12528 if(s_version >= 52)
18245
1/2
✓ Branch 0 taken 4907 times.
✗ Branch 1 not taken.
4907 if(!p_getc(&count, f))
18246 return qe_invalid;
18247
18248
2/2
✓ Branch 0 taken 12591 times.
✓ Branch 1 taken 12528 times.
25119 for(byte q = 0; q < count; ++q)
18249 {
18250 12591 combo_trigger& temp_trigger = temp_combo.triggers.emplace_back();
18251 12591 auto ret = readcombo_triggers_loop(f, s_version, temp_trigger);
18252
1/2
✓ Branch 0 taken 12591 times.
✗ Branch 1 not taken.
12591 if(ret)
18253 return ret;
18254 12591 }
18255
18256
2/2
✓ Branch 0 taken 7621 times.
✓ Branch 1 taken 4907 times.
12528 if(s_version < 52)
18257 {
18258
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7621 times.
7621 if(!temp_combo.triggers.empty())
18259 7621 temp_combo.only_gentrig = (temp_combo.triggers[0].triggerflags[0] & combotriggerONLYGENTRIG) ? 1 : 0;
18260 7621 }
18261
1/2
✓ Branch 0 taken 4907 times.
✗ Branch 1 not taken.
4907 else if(!p_getc(&temp_combo.only_gentrig,f))
18262 return qe_invalid;
18263 12528 }
18264
2/2
✓ Branch 0 taken 655382 times.
✓ Branch 1 taken 572 times.
655954 if(combo_has_flags&CHAS_LIFT)
18265 {
18266
1/2
✓ Branch 0 taken 572 times.
✗ Branch 1 not taken.
572 if(!p_igetw(&temp_combo.liftcmb,f))
18267 return qe_invalid;
18268
1/2
✓ Branch 0 taken 572 times.
✗ Branch 1 not taken.
572 if(!p_getc(&temp_combo.liftcs,f))
18269 return qe_invalid;
18270
1/2
✓ Branch 0 taken 572 times.
✗ Branch 1 not taken.
572 if(!p_igetw(&temp_combo.liftundercmb,f))
18271 return qe_invalid;
18272
1/2
✓ Branch 0 taken 572 times.
✗ Branch 1 not taken.
572 if(!p_getc(&temp_combo.liftundercs,f))
18273 return qe_invalid;
18274
1/2
✓ Branch 0 taken 572 times.
✗ Branch 1 not taken.
572 if(!p_getc(&temp_combo.liftdmg,f))
18275 return qe_invalid;
18276
1/2
✓ Branch 0 taken 572 times.
✗ Branch 1 not taken.
572 if(!p_getc(&temp_combo.liftlvl,f))
18277 return qe_invalid;
18278
1/2
✓ Branch 0 taken 572 times.
✗ Branch 1 not taken.
572 if(!p_getc(&temp_combo.liftitm,f))
18279 return qe_invalid;
18280
1/2
✓ Branch 0 taken 572 times.
✗ Branch 1 not taken.
572 if(!p_getc(&temp_combo.liftflags,f))
18281 return qe_invalid;
18282
1/2
✓ Branch 0 taken 572 times.
✗ Branch 1 not taken.
572 if(!p_getc(&temp_combo.liftgfx,f))
18283 return qe_invalid;
18284
1/2
✓ Branch 0 taken 572 times.
✗ Branch 1 not taken.
572 if(!p_getc(&temp_combo.liftsprite,f))
18285 return qe_invalid;
18286
1/2
✓ Branch 0 taken 572 times.
✗ Branch 1 not taken.
572 if(!p_getc(&temp_combo.liftsfx,f))
18287 return qe_invalid;
18288
1/2
✓ Branch 0 taken 572 times.
✗ Branch 1 not taken.
572 if(!p_igetw(&temp_combo.liftbreaksprite,f))
18289 return qe_invalid;
18290
1/2
✓ Branch 0 taken 572 times.
✗ Branch 1 not taken.
572 if(!p_getc(&temp_combo.liftbreaksfx,f))
18291 return qe_invalid;
18292
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 572 times.
572 if(s_version >= 34)
18293 {
18294
1/2
✓ Branch 0 taken 572 times.
✗ Branch 1 not taken.
572 if(!p_getc(&temp_combo.lifthei,f))
18295 return qe_invalid;
18296
1/2
✓ Branch 0 taken 572 times.
✗ Branch 1 not taken.
572 if(!p_getc(&temp_combo.lifttime,f))
18297 return qe_invalid;
18298 572 }
18299
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 558 times.
572 if(s_version >= 39)
18300 {
18301
1/2
✓ Branch 0 taken 558 times.
✗ Branch 1 not taken.
558 if(!p_getc(&temp_combo.lift_parent_item,f))
18302 return qe_invalid;
18303 558 }
18304
2/2
✓ Branch 0 taken 117 times.
✓ Branch 1 taken 455 times.
572 if(s_version >= 51)
18305 {
18306
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 455 times.
455 if(!p_getc(&temp_combo.liftlightrad,f))
18307 return qe_invalid;
18308
1/2
✓ Branch 0 taken 455 times.
✗ Branch 1 not taken.
455 if(!p_getc(&temp_combo.liftlightshape,f))
18309 return qe_invalid;
18310 455 }
18311 572 }
18312
2/2
✓ Branch 0 taken 623795 times.
✓ Branch 1 taken 32159 times.
655954 if(combo_has_flags&CHAS_GENERAL)
18313 {
18314
1/2
✓ Branch 0 taken 32159 times.
✗ Branch 1 not taken.
32159 if(!p_getc(&temp_combo.speed_mult,f))
18315 return qe_invalid;
18316
1/2
✓ Branch 0 taken 32159 times.
✗ Branch 1 not taken.
32159 if(!p_getc(&temp_combo.speed_div,f))
18317 return qe_invalid;
18318
1/2
✓ Branch 0 taken 32159 times.
✗ Branch 1 not taken.
32159 if(!p_igetzf(&temp_combo.speed_add,f))
18319 return qe_invalid;
18320
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32159 times.
32159 if(s_version >= 42)
18321 {
18322
1/2
✓ Branch 0 taken 32159 times.
✗ Branch 1 not taken.
32159 if(!p_getc(&temp_combo.sfx_appear,f))
18323 return qe_invalid;
18324
1/2
✓ Branch 0 taken 32159 times.
✗ Branch 1 not taken.
32159 if(!p_getc(&temp_combo.sfx_disappear,f))
18325 return qe_invalid;
18326
1/2
✓ Branch 0 taken 32159 times.
✗ Branch 1 not taken.
32159 if(!p_getc(&temp_combo.sfx_loop,f))
18327 return qe_invalid;
18328
1/2
✓ Branch 0 taken 32159 times.
✗ Branch 1 not taken.
32159 if(!p_getc(&temp_combo.sfx_walking,f))
18329 return qe_invalid;
18330
1/2
✓ Branch 0 taken 32159 times.
✗ Branch 1 not taken.
32159 if(!p_getc(&temp_combo.sfx_standing,f))
18331 return qe_invalid;
18332
1/2
✓ Branch 0 taken 32159 times.
✗ Branch 1 not taken.
32159 if(!p_getc(&temp_combo.spr_appear,f))
18333 return qe_invalid;
18334
1/2
✓ Branch 0 taken 32159 times.
✗ Branch 1 not taken.
32159 if(!p_getc(&temp_combo.spr_disappear,f))
18335 return qe_invalid;
18336
1/2
✓ Branch 0 taken 32159 times.
✗ Branch 1 not taken.
32159 if(!p_getc(&temp_combo.spr_walking,f))
18337 return qe_invalid;
18338
1/2
✓ Branch 0 taken 32159 times.
✗ Branch 1 not taken.
32159 if(!p_getc(&temp_combo.spr_standing,f))
18339 return qe_invalid;
18340 32159 }
18341
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32159 times.
32159 if(s_version >= 44)
18342 {
18343
1/2
✓ Branch 0 taken 32159 times.
✗ Branch 1 not taken.
32159 if(!p_getc(&temp_combo.sfx_tap,f))
18344 return qe_invalid;
18345 32159 }
18346
2/2
✓ Branch 0 taken 366 times.
✓ Branch 1 taken 31793 times.
32159 if(s_version >= 49)
18347 {
18348
1/2
✓ Branch 0 taken 31793 times.
✗ Branch 1 not taken.
31793 if(!p_getc(&temp_combo.sfx_landing,f))
18349 return qe_invalid;
18350 31793 }
18351
2/2
✓ Branch 0 taken 366 times.
✓ Branch 1 taken 31793 times.
32159 if(s_version >= 50)
18352 {
18353
1/2
✓ Branch 0 taken 31793 times.
✗ Branch 1 not taken.
31793 if(!p_getc(&temp_combo.spr_falling,f))
18354 return qe_invalid;
18355
1/2
✓ Branch 0 taken 31793 times.
✗ Branch 1 not taken.
31793 if(!p_getc(&temp_combo.spr_drowning,f))
18356 return qe_invalid;
18357
1/2
✓ Branch 0 taken 31793 times.
✗ Branch 1 not taken.
31793 if(!p_getc(&temp_combo.spr_lava_drowning,f))
18358 return qe_invalid;
18359
1/2
✓ Branch 0 taken 31793 times.
✗ Branch 1 not taken.
31793 if(!p_getc(&temp_combo.sfx_falling,f))
18360 return qe_invalid;
18361
1/2
✓ Branch 0 taken 31793 times.
✗ Branch 1 not taken.
31793 if(!p_getc(&temp_combo.sfx_drowning,f))
18362 return qe_invalid;
18363
1/2
✓ Branch 0 taken 31793 times.
✗ Branch 1 not taken.
31793 if(!p_getc(&temp_combo.sfx_lava_drowning,f))
18364 return qe_invalid;
18365 31793 }
18366 32159 }
18367 655954 }
18368 1454681 update_combo(temp_combo, s_version);
18369 1454681 return 0;
18370 1454681 }
18371
18372 478 int32_t readcombos(PACKFILE *f, zquestheader *Header, word version, word build, word start_combo, word max_combos)
18373 {
18374
2/2
✓ Branch 0 taken 454 times.
✓ Branch 1 taken 24 times.
478 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_combos);
18375
18376 478 word section_version=0;
18377 478 word combos_used=0;
18378 int32_t dummy;
18379 byte padding;
18380 478 newcombo temp_combo;
18381
18382
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 477 times.
478 if (!should_skip)
18383 {
18384
1/2
✓ Branch 0 taken 477 times.
✗ Branch 1 not taken.
477 reset_all_combo_animations();
18385
1/2
✓ Branch 0 taken 477 times.
✗ Branch 1 not taken.
477 init_combo_classes();
18386
18387
2/2
✓ Branch 0 taken 31138560 times.
✓ Branch 1 taken 477 times.
31139037 for(int32_t q = start_combo; q < start_combo+max_combos; ++q)
18388
1/2
✓ Branch 0 taken 31138560 times.
✗ Branch 1 not taken.
31138560 combobuf[q].clear();
18389 477 }
18390
18391
2/2
✓ Branch 0 taken 454 times.
✓ Branch 1 taken 24 times.
478 if(version > 0x192) //Version info
18392 {
18393
2/4
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 454 times.
✗ Branch 3 not taken.
454 if(!p_igetw(&section_version,f))
18394 {
18395 return qe_invalid;
18396 }
18397 454 FFCore.quest_format[vCombos] = section_version;
18398
2/4
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 454 times.
✗ Branch 3 not taken.
454 if(!read_deprecated_section_cversion(f))
18399 {
18400 return qe_invalid;
18401 }
18402
18403 //section size
18404
2/4
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 454 times.
✗ Branch 3 not taken.
454 if(!p_igetl(&dummy,f))
18405 {
18406 return qe_invalid;
18407 }
18408 454 }
18409
18410
2/2
✓ Branch 0 taken 185 times.
✓ Branch 1 taken 293 times.
478 if(section_version > 32) //Cleanup time!
18411 {
18412
2/4
✓ Branch 0 taken 185 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 185 times.
✗ Branch 3 not taken.
185 if(!p_igetw(&combos_used,f))
18413 {
18414 return qe_invalid;
18415 }
18416
2/2
✓ Branch 0 taken 1454681 times.
✓ Branch 1 taken 185 times.
1454866 for(int32_t i=0; i<combos_used; i++)
18417 {
18418
1/2
✓ Branch 0 taken 1454681 times.
✗ Branch 1 not taken.
1454681 auto ret = readcombo_loop(f,section_version,temp_combo);
18419
1/2
✓ Branch 0 taken 1454681 times.
✗ Branch 1 not taken.
1454681 if(ret) return ret;
18420
1/2
✓ Branch 0 taken 1454681 times.
✗ Branch 1 not taken.
1454681 if(i>=start_combo)
18421 {
18422
1/2
✓ Branch 0 taken 1454681 times.
✗ Branch 1 not taken.
1454681 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
18423 {
18424 temp_combo.script = 0;
18425 for(int q = 0; q < 8; ++q)
18426 temp_combo.initd[q] = 0;
18427 }
18428
1/2
✓ Branch 0 taken 1454681 times.
✗ Branch 1 not taken.
1454681 combobuf[i] = temp_combo;
18429 1454681 }
18430 1454681 }
18431 185 }
18432 else //Call the old function for all old versions
18433 {
18434
1/2
✓ Branch 0 taken 293 times.
✗ Branch 1 not taken.
293 auto ret = readcombos_old(section_version,f,Header,version,build,start_combo,max_combos);
18435
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 293 times.
293 if(ret) return ret; //error, end read
18436 }
18437
18438
2/2
✓ Branch 0 taken 477 times.
✓ Branch 1 taken 1 times.
478 if (should_skip)
18439 1 return 0;
18440
18441
2/2
✓ Branch 0 taken 301 times.
✓ Branch 1 taken 176 times.
477 if(!get_qr(qr_ALLOW_EDITING_COMBO_0))
18442 {
18443 176 combobuf[0].walk = 0xF0;
18444 176 combobuf[0].type = 0;
18445 176 combobuf[0].flag = 0;
18446 176 }
18447
18448
1/2
✓ Branch 0 taken 477 times.
✗ Branch 1 not taken.
477 setup_combo_animations();
18449
1/2
✓ Branch 0 taken 477 times.
✗ Branch 1 not taken.
477 setup_combo_animations2();
18450 477 return 0;
18451 478 }
18452
18453 395 int32_t readcomboaliases(PACKFILE *f, zquestheader *Header, word version, word build)
18454 {
18455 //these are here to bypass compiler warnings about unused arguments
18456 395 Header=Header;
18457 395 version=version;
18458 395 build=build;
18459
18460 int32_t dummy;
18461 395 word sversion=0, c_sversion;
18462
18463 //section version info
18464
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 395 times.
395 if(!p_igetw(&sversion,f))
18465 {
18466 return qe_invalid;
18467 }
18468
18469 395 FFCore.quest_format[vComboAliases] = sversion;
18470
18471
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 if(!p_igetw(&c_sversion,f))
18472 {
18473 return qe_invalid;
18474 }
18475
18476 //section size
18477
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 if(!p_igetl(&dummy,f))
18478 {
18479 return qe_invalid;
18480 }
18481
18482 395 int32_t max_num_combo_aliases = MAXCOMBOALIASES;
18483
18484
2/2
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 205 times.
395 if(sversion < 3) // max saved combo alias' upped from 256 to 2048.
18485 {
18486 205 max_num_combo_aliases = MAX250COMBOALIASES;
18487 205 }
18488
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 if(sversion < 2) // max saved combo alias' upped from 256 to 2048.
18489 {
18490 max_num_combo_aliases = OLDMAXCOMBOALIASES;
18491 }
18492
18493
2/2
✓ Branch 0 taken 1976320 times.
✓ Branch 1 taken 395 times.
1976715 for(int32_t j=0; j<max_num_combo_aliases; j++)
18494 {
18495 byte width,height,mask,tempcset;
18496 int32_t count;
18497 word tempword;
18498 byte tempbyte;
18499
18500
1/2
✓ Branch 0 taken 1976320 times.
✗ Branch 1 not taken.
1976320 if(!p_igetw(&tempword,f))
18501 {
18502 return qe_invalid;
18503 }
18504
18505 1976320 combo_aliases[j].combo = tempword;
18506
18507
1/2
✓ Branch 0 taken 1976320 times.
✗ Branch 1 not taken.
1976320 if(!p_getc(&tempbyte,f))
18508 {
18509 return qe_invalid;
18510 }
18511
18512 1976320 combo_aliases[j].cset = tempbyte;
18513
18514
1/2
✓ Branch 0 taken 1976320 times.
✗ Branch 1 not taken.
1976320 if(!p_getc(&width,f))
18515 {
18516 return qe_invalid;
18517 }
18518
18519
1/2
✓ Branch 0 taken 1976320 times.
✗ Branch 1 not taken.
1976320 if(!p_getc(&height,f))
18520 {
18521 return qe_invalid;
18522 }
18523
18524
1/2
✓ Branch 0 taken 1976320 times.
✗ Branch 1 not taken.
1976320 if(!p_getc(&mask,f))
18525 {
18526 return qe_invalid;
18527 }
18528
18529 1976320 count=(width+1)*(height+1)*(comboa_lmasktotal(mask)+1);
18530
18531 1976320 combo_aliases[j].width = width;
18532 1976320 combo_aliases[j].height = height;
18533 1976320 combo_aliases[j].layermask = mask;
18534 1976320 combo_aliases[j].combos.clear();
18535 1976320 combo_aliases[j].csets.clear();
18536
18537
2/2
✓ Branch 0 taken 2028682 times.
✓ Branch 1 taken 1976320 times.
4005002 for(int32_t k=0; k<count; k++)
18538 {
18539
1/2
✓ Branch 0 taken 2028682 times.
✗ Branch 1 not taken.
2028682 if(!p_igetw(&tempword,f))
18540 {
18541 return qe_invalid;
18542 }
18543
18544 2028682 combo_aliases[j].combos[k] = tempword;
18545 2028682 }
18546
18547
2/2
✓ Branch 0 taken 2028682 times.
✓ Branch 1 taken 1976320 times.
4005002 for(int32_t k=0; k<count; k++)
18548 {
18549
1/2
✓ Branch 0 taken 2028682 times.
✗ Branch 1 not taken.
2028682 if(!p_getc(&tempcset,f))
18550 {
18551 return qe_invalid;
18552 }
18553
18554 2028682 combo_aliases[j].csets[k] = tempcset;
18555 2028682 }
18556 1976320 }
18557
18558 //Combo pools!
18559 395 word num_combo_pools = 0;
18560
2/2
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 185 times.
395 if(sversion >= 4)
18561 {
18562
1/2
✓ Branch 0 taken 185 times.
✗ Branch 1 not taken.
185 if(!p_igetw(&num_combo_pools,f))
18563 {
18564 return qe_invalid;
18565 }
18566 185 }
18567
18568
2/2
✓ Branch 0 taken 3235840 times.
✓ Branch 1 taken 395 times.
3236235 for(combo_pool& pool : combo_pools)
18569 {
18570 3235840 pool.clear();
18571 }
18572
18573 395 combo_pool temp_cpool;
18574
2/2
✓ Branch 0 taken 466 times.
✓ Branch 1 taken 395 times.
861 for(word cp = 0; cp < num_combo_pools; ++cp)
18575 {
18576 466 int32_t num_combos_in_pool = 0;
18577
2/4
✓ Branch 0 taken 466 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 466 times.
✗ Branch 3 not taken.
466 if(!p_igetl(&num_combos_in_pool,f))
18578 {
18579 return qe_invalid;
18580 }
18581
2/2
✓ Branch 0 taken 370 times.
✓ Branch 1 taken 96 times.
466 if(num_combos_in_pool < 1) continue; //nothing to read
18582
18583
1/2
✓ Branch 0 taken 370 times.
✗ Branch 1 not taken.
370 temp_cpool.clear();
18584
18585 int32_t cp_cid; int8_t cp_cs; word cp_quant;
18586
2/2
✓ Branch 0 taken 370 times.
✓ Branch 1 taken 1671 times.
2041 for(auto q = 0; q < num_combos_in_pool; ++q)
18587 {
18588
2/4
✓ Branch 0 taken 1671 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1671 times.
✗ Branch 3 not taken.
1671 if(!p_igetl(&cp_cid,f))
18589 {
18590 return qe_invalid;
18591 }
18592
2/4
✓ Branch 0 taken 1671 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1671 times.
✗ Branch 3 not taken.
1671 if(!p_getc(&cp_cs,f))
18593 {
18594 return qe_invalid;
18595 }
18596
2/4
✓ Branch 0 taken 1671 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1671 times.
✗ Branch 3 not taken.
1671 if(!p_igetw(&cp_quant,f))
18597 {
18598 return qe_invalid;
18599 }
18600
1/2
✓ Branch 0 taken 1671 times.
✗ Branch 1 not taken.
1671 temp_cpool.add(cp_cid, cp_cs, cp_quant);
18601 1671 }
18602
18603
1/2
✓ Branch 0 taken 370 times.
✗ Branch 1 not taken.
370 combo_pools[cp] = temp_cpool;
18604 370 }
18605
18606 //Autocombos!
18607 395 word num_combo_autos = 0;
18608
2/2
✓ Branch 0 taken 173 times.
✓ Branch 1 taken 222 times.
395 if (sversion >= 5)
18609 {
18610
2/4
✓ Branch 0 taken 173 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 173 times.
✗ Branch 3 not taken.
173 if (!p_igetw(&num_combo_autos, f))
18611 {
18612 return qe_invalid;
18613 }
18614 173 }
18615
18616
2/2
✓ Branch 0 taken 395 times.
✓ Branch 1 taken 3235840 times.
3236235 for (combo_auto& cauto : combo_autos)
18617 {
18618
1/2
✓ Branch 0 taken 3235840 times.
✗ Branch 1 not taken.
3235840 cauto.clear(true);
18619 }
18620
18621
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 combo_auto temp_cauto;
18622
2/2
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 395 times.
521 for (word ca = 0; ca < num_combo_autos; ++ca)
18623 {
18624 byte type;
18625 int32_t display_cid, erase_cid;
18626 byte flags, arg;
18627
2/4
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
126 if (!p_getc(&type, f))
18628 {
18629 return qe_invalid;
18630 }
18631
2/4
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
126 if (!p_igetl(&display_cid, f))
18632 {
18633 return qe_invalid;
18634 }
18635
2/4
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
126 if (!p_igetl(&erase_cid, f))
18636 {
18637 return qe_invalid;
18638 }
18639
2/4
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
126 if (!p_getc(&flags, f))
18640 {
18641 return qe_invalid;
18642 }
18643
2/4
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
126 if (!p_getc(&arg, f))
18644 {
18645 return qe_invalid;
18646 }
18647 126 int32_t num_combos_in_cauto = 0;
18648
2/4
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
126 if (!p_igetl(&num_combos_in_cauto, f))
18649 {
18650 return qe_invalid;
18651 }
18652
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 21 times.
126 if (num_combos_in_cauto < 1) continue; //nothing to read
18653
18654
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 temp_cauto.clear();
18655
18656
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 temp_cauto.setType(type);
18657
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 temp_cauto.setDisplay(display_cid);
18658
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 temp_cauto.setEraseCombo(erase_cid);
18659
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 temp_cauto.setFlags(flags);
18660
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 temp_cauto.setArg(arg);
18661
18662 int32_t ca_cid; byte ca_ctype; int16_t ca_offset; int16_t ca_engrave_offset;
18663
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 2361 times.
2466 for (auto q = 0; q < num_combos_in_cauto; ++q)
18664 {
18665
2/4
✓ Branch 0 taken 2361 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2361 times.
✗ Branch 3 not taken.
2361 if (!p_getc(&ca_ctype, f))
18666 {
18667 return qe_invalid;
18668 }
18669
2/4
✓ Branch 0 taken 2361 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2361 times.
✗ Branch 3 not taken.
2361 if (!p_igetl(&ca_cid, f))
18670 {
18671 return qe_invalid;
18672 }
18673
1/2
✓ Branch 0 taken 2361 times.
✗ Branch 1 not taken.
2361 temp_cauto.addEntry(ca_cid, ca_ctype, q, -1);
18674 2361 }
18675
18676
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 combo_autos[ca] = temp_cauto;
18677 105 }
18678
18679 395 return 0;
18680 395 }
18681
18682 798 int32_t readcolordata(PACKFILE *f, miscQdata *Misc, word version, word build, word start_cset, word max_csets)
18683 {
18684
2/2
✓ Branch 0 taken 774 times.
✓ Branch 1 taken 24 times.
798 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_colors);
18685
18686 //these are here to bypass compiler warnings about unused arguments
18687 //THE *48 REFERS TO EACH CSET BEING 16 COLORS with 3 VALUES OF RGB (3*16 is 48)
18688 //Capitalized cause it'll save you a headache. -Deedee
18689 798 start_cset=start_cset;
18690 798 max_csets=max_csets;
18691 798 word s_version=0;
18692
18693 miscQdata temp_misc;
18694 798 memcpy(&temp_misc, Misc, sizeof(temp_misc));
18695
18696 byte temp_colordata[48];
18697 char temp_palname[PALNAMESIZE+1];
18698
18699 int32_t dummy;
18700 word palcycles;
18701
18702
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 774 times.
798 if(version > 0x192)
18703 {
18704 //section version info
18705
1/2
✓ Branch 0 taken 774 times.
✗ Branch 1 not taken.
774 if(!p_igetw(&s_version,f))
18706 {
18707 return qe_invalid;
18708 }
18709
18710 774 FFCore.quest_format[vCSets] = s_version;
18711
18712
1/2
✓ Branch 0 taken 774 times.
✗ Branch 1 not taken.
774 if(!p_igetw(&dummy,f))
18713 {
18714 return qe_invalid;
18715 }
18716
18717 //section size
18718
1/2
✓ Branch 0 taken 774 times.
✗ Branch 1 not taken.
774 if(!p_igetl(&dummy,f))
18719 {
18720 return qe_invalid;
18721 }
18722 774 }
18723
2/2
✓ Branch 0 taken 608 times.
✓ Branch 1 taken 190 times.
798 if (s_version < 5)
18724 {
18725
4/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 590 times.
✓ Branch 2 taken 584 times.
✓ Branch 3 taken 6 times.
608 bool RealOldVerion = ((version < 0x192)||((version == 0x192)&&(build<73)));
18726
18727 //finally... section data
18728 608 int32_t q = 0;
18729 608 int32_t p = -15;
18730
2/2
✓ Branch 0 taken 145920 times.
✓ Branch 1 taken 608 times.
146528 for(int32_t i=0; i<oldpdTOTAL; ++i)
18731 {
18732 145920 memset(temp_colordata, 0, 48);
18733
18734
1/2
✓ Branch 0 taken 145920 times.
✗ Branch 1 not taken.
145920 if(!pfread(temp_colordata,48,f))
18735 {
18736 return qe_invalid;
18737 }
18738
18739
2/2
✓ Branch 0 taken 240 times.
✓ Branch 1 taken 145680 times.
145920 if (should_skip)
18740 240 continue;
18741
18742 145680 memcpy(&colordata[q*48], temp_colordata, 48);
18743
18744 145680 ++q;
18745
8/8
✓ Branch 0 taken 135968 times.
✓ Branch 1 taken 9712 times.
✓ Branch 2 taken 10319 times.
✓ Branch 3 taken 125649 times.
✓ Branch 4 taken 1214 times.
✓ Branch 5 taken 9105 times.
✓ Branch 6 taken 36 times.
✓ Branch 7 taken 1178 times.
145680 if (p > 0 && (p%13)==12 && (i < oldpoSPRITE || !RealOldVerion)) //It's > 0 instead of >= 0 because it should append
18746 {
18747
1/2
✓ Branch 0 taken 10283 times.
✗ Branch 1 not taken.
10283 if (s_version < 5) //Bumping up the size of level palettes
18748 {
18749 10283 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18750 10283 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18751 10283 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18752 10283 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18753 10283 q+=4;
18754 10283 }
18755 else
18756 {
18757 for(int m = 0; m < 4; ++m)
18758 {
18759 memset(temp_colordata, 0, 48);
18760 if(!pfread(temp_colordata,48,f))
18761 {
18762 return qe_invalid;
18763 }
18764 memcpy(&colordata[q*48], temp_colordata, 48);
18765 ++q;
18766 }
18767 }
18768 10283 }
18769 145680 ++p;
18770 145680 }
18771
18772
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 590 times.
608 if(RealOldVerion)
18773 {
18774
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if (!should_skip)
18775 {
18776 18 memcpy(colordata+(poSPRITE255*48), colordata+((q-30)*48), 30*16*3);
18777 18 memset(colordata+((q-30)*48), 0, ((poSPRITE255-(q-30))*48));
18778 18 memcpy(colordata+((poSPRITE255+11)*48), colordata+((poSPRITE255+10)*48), 48);
18779 18 memcpy(colordata+((poSPRITE255+10)*48), colordata+((poSPRITE255+9)*48), 48);
18780 18 memcpy(colordata+((poSPRITE255+9)*48), colordata+((poSPRITE255+8)*48), 48);
18781 18 memset(colordata+((poSPRITE255+8)*48), 0, 48);
18782 18 }
18783 18 }
18784 else
18785 {
18786 590 memset(temp_colordata, 0, 48);
18787
18788
2/2
✓ Branch 0 taken 1848470 times.
✓ Branch 1 taken 590 times.
1849060 for(int32_t i=0; i<newpdTOTAL-oldpdTOTAL; ++i)
18789 {
18790
1/2
✓ Branch 0 taken 1848470 times.
✗ Branch 1 not taken.
1848470 if(!pfread(temp_colordata,48,f))
18791 {
18792 return qe_invalid;
18793 }
18794
18795
2/2
✓ Branch 0 taken 3133 times.
✓ Branch 1 taken 1845337 times.
1848470 if (should_skip)
18796 3133 continue;
18797
18798 1845337 memcpy(&colordata[q*48], temp_colordata, 48);
18799
18800 1845337 ++q;
18801
7/8
✓ Branch 0 taken 1845337 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 141949 times.
✓ Branch 3 taken 1703388 times.
✓ Branch 4 taken 1178 times.
✓ Branch 5 taken 140771 times.
✓ Branch 6 taken 1050 times.
✓ Branch 7 taken 128 times.
1845337 if (p > 0 && (p%13)==12 && (i < (newpoSPRITE-oldpdTOTAL) || (s_version >= 4))) //It's > 0 instead of >= 0 because it should append
18802 {
18803
1/2
✓ Branch 0 taken 141821 times.
✗ Branch 1 not taken.
141821 if (s_version < 5) //Bumping up the size of level palettes
18804 {
18805 141821 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18806 141821 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18807 141821 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18808 141821 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18809 141821 q+=4;
18810 141821 }
18811 else
18812 {
18813 for(int m = 0; m < 4; ++m)
18814 {
18815 memset(temp_colordata, 0, 48);
18816 if(!pfread(temp_colordata,48,f))
18817 {
18818 return qe_invalid;
18819 }
18820 memcpy(&colordata[q*48], temp_colordata, 48);
18821 ++q;
18822 }
18823 }
18824 141821 }
18825 1845337 ++p;
18826 1845337 }
18827
18828
2/2
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 525 times.
590 if(s_version < 4)
18829 {
18830
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 64 times.
65 if (!should_skip)
18831 {
18832 64 memcpy(colordata+(poSPRITE255*48), colordata+((q-30)*48), 30*16*3);
18833 64 memset(colordata+((q-30)*48), 0, ((poSPRITE255-(q-30))*48));
18834 64 }
18835 65 }
18836 else
18837 {
18838
2/2
✓ Branch 0 taken 1747200 times.
✓ Branch 1 taken 525 times.
1747725 for(int32_t i=0; i<newerpdTOTAL-newpdTOTAL; ++i)
18839 {
18840
1/2
✓ Branch 0 taken 1747200 times.
✗ Branch 1 not taken.
1747200 if(!pfread(temp_colordata,48,f))
18841 {
18842 return qe_invalid;
18843 }
18844
18845
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1747200 times.
1747200 if (should_skip)
18846 continue;
18847
18848 1747200 memcpy(&colordata[q*48], temp_colordata, 48);
18849 1747200 ++q;
18850
5/6
✓ Branch 0 taken 1747200 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 134400 times.
✓ Branch 3 taken 1612800 times.
✓ Branch 4 taken 1050 times.
✓ Branch 5 taken 133350 times.
1747200 if (p > 0 && (p%13)==12 && i < newerpoSPRITE-newpdTOTAL) //It's > 0 instead of >= 0 because it should append
18851 {
18852
1/2
✓ Branch 0 taken 133350 times.
✗ Branch 1 not taken.
133350 if (s_version < 5) //Bumping up the size of level palettes
18853 {
18854 133350 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18855 133350 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18856 133350 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18857 133350 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18858 133350 q+=4;
18859 133350 }
18860 else
18861 {
18862 for(int m = 0; m < 4; ++m)
18863 {
18864 memset(temp_colordata, 0, 48);
18865 if(!pfread(temp_colordata,48,f))
18866 {
18867 return qe_invalid;
18868 }
18869 memcpy(&colordata[q*48], temp_colordata, 48);
18870 ++q;
18871 }
18872 }
18873 133350 }
18874 1747200 ++p;
18875 1747200 }
18876
18877 //By this point, q should be about equal to pdTOTAL255. If it isn't, I've fucked up. -Deedee
18878 }
18879 }
18880 608 }
18881 else
18882 {
18883
2/2
✓ Branch 0 taken 1662310 times.
✓ Branch 1 taken 190 times.
1662500 for(int32_t i=0; i<pdTOTAL255; ++i)
18884 {
18885 1662310 memset(temp_colordata, 0, 48);
18886
18887
1/2
✓ Branch 0 taken 1662310 times.
✗ Branch 1 not taken.
1662310 if(!pfread(temp_colordata,48,f))
18888 {
18889 return qe_invalid;
18890 }
18891
18892 1662310 memcpy(&colordata[i*48], temp_colordata, 48);
18893 1662310 }
18894 }
18895
18896
4/4
✓ Branch 0 taken 797 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 145 times.
✓ Branch 3 taken 652 times.
798 if (!should_skip && s_version < 6)
18897 {
18898
2/2
✓ Branch 0 taken 273808704 times.
✓ Branch 1 taken 652 times.
273809356 for (int i = 0; i < psTOTAL255; i++)
18899 {
18900 273808704 colordata[i] = _rgb_scale_6[colordata[i]];
18901 273808704 }
18902 652 }
18903
18904
5/6
✓ Branch 0 taken 780 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 774 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
798 if((version < 0x192)||((version == 0x192)&&(build<76)))
18905 {
18906
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if (!should_skip)
18907 18 init_palnames();
18908 18 }
18909 else
18910 {
18911 780 int32_t palnamestoread = 0;
18912
18913
2/2
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 715 times.
780 if(s_version < 3)
18914 65 palnamestoread = OLDMAXLEVELS;
18915 else
18916 715 palnamestoread = 512;
18917
18918
2/2
✓ Branch 0 taken 382720 times.
✓ Branch 1 taken 780 times.
383500 for(int32_t i=0; i<palnamestoread; ++i)
18919 {
18920
1/2
✓ Branch 0 taken 382720 times.
✗ Branch 1 not taken.
382720 if(!p_getstr(temp_palname,PALNAMESIZE,f))
18921 {
18922 return qe_invalid;
18923 }
18924
18925
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 382464 times.
382720 if (!should_skip)
18926 382464 memcpy(palnames[i], temp_palname, PALNAMESIZE);
18927 382720 }
18928
18929
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 779 times.
780 if (should_skip)
18930 1 return 0;
18931
18932
2/2
✓ Branch 0 taken 16384 times.
✓ Branch 1 taken 779 times.
17163 for(int32_t i=palnamestoread; i<MAXLEVELS; i++)
18933 {
18934 16384 memset(palnames[i], 0, PALNAMESIZE);
18935 16384 }
18936 }
18937
18938
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 774 times.
797 if(version > 0x192)
18939 {
18940
2/2
✓ Branch 0 taken 198144 times.
✓ Branch 1 taken 774 times.
198918 for(int32_t i=0; i<256; i++)
18941 {
18942
2/2
✓ Branch 0 taken 594432 times.
✓ Branch 1 taken 198144 times.
792576 for(int32_t j=0; j<3; j++)
18943 {
18944 594432 temp_misc.cycles[i][j].first=0;
18945 594432 temp_misc.cycles[i][j].count=0;
18946 594432 temp_misc.cycles[i][j].speed=0;
18947 594432 }
18948 198144 }
18949
18950
1/2
✓ Branch 0 taken 774 times.
✗ Branch 1 not taken.
774 if(!p_igetw(&palcycles,f))
18951 {
18952 return qe_invalid;
18953 }
18954
18955
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 774 times.
774 if (palcycles > NUM_PAL_CYCLES)
18956 {
18957 return qe_invalid;
18958 }
18959
18960
2/2
✓ Branch 0 taken 22277 times.
✓ Branch 1 taken 774 times.
23051 for(int32_t i=0; i<palcycles; i++)
18961 {
18962
2/2
✓ Branch 0 taken 66831 times.
✓ Branch 1 taken 22277 times.
89108 for(int32_t j=0; j<3; j++)
18963 {
18964
1/2
✓ Branch 0 taken 66831 times.
✗ Branch 1 not taken.
66831 if(!p_getc(&temp_misc.cycles[i][j].first,f))
18965 {
18966 return qe_invalid;
18967 }
18968 66831 }
18969
18970
2/2
✓ Branch 0 taken 66831 times.
✓ Branch 1 taken 22277 times.
89108 for(int32_t j=0; j<3; j++)
18971 {
18972
1/2
✓ Branch 0 taken 66831 times.
✗ Branch 1 not taken.
66831 if(!p_getc(&temp_misc.cycles[i][j].count,f))
18973 {
18974 return qe_invalid;
18975 }
18976 66831 }
18977
18978
2/2
✓ Branch 0 taken 66831 times.
✓ Branch 1 taken 22277 times.
89108 for(int32_t j=0; j<3; j++)
18979 {
18980
1/2
✓ Branch 0 taken 66831 times.
✗ Branch 1 not taken.
66831 if(!p_getc(&temp_misc.cycles[i][j].speed,f))
18981 {
18982 return qe_invalid;
18983 }
18984 66831 }
18985 22277 }
18986
18987 774 memcpy(Misc, &temp_misc, sizeof(temp_misc));
18988 774 }
18989
18990 797 return 0;
18991 798 }
18992
18993 798 int32_t readtiles(PACKFILE *f, tiledata *buf, zquestheader *Header, word version, word build, word start_tile, int32_t max_tiles, bool from_init)
18994 {
18995
2/2
✓ Branch 0 taken 774 times.
✓ Branch 1 taken 24 times.
798 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_tiles);
18996
18997 798 int32_t tiles_used=0;
18998 798 word section_version = 0;
18999 798 int32_t section_size= 0;
19000 798 byte *temp_tile = new byte[tilesize(tf32Bit)];
19001
19002 //Tile Expansion
19003 //if ( version >= 0x254 && build >= 41 )
19004
4/4
✓ Branch 0 taken 608 times.
✓ Branch 1 taken 190 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 602 times.
798 if (version < 0x254 && build < 41)
19005 {
19006 602 max_tiles = ZC250MAXTILES;
19007 602 }
19008
19009
19010
2/6
✓ Branch 0 taken 798 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 798 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
798 if(Header!=NULL&&(!Header->data_flags[ZQ_TILES]&&!from_init)) //keep for old quests
19011 {
19012 if(!init_tiles_for_190(true, Header))
19013 {
19014 al_trace("Unable to initialize tiles\n");
19015 }
19016
19017 delete[] temp_tile;
19018 temp_tile=NULL;
19019 return 0;
19020 }
19021 else
19022 {
19023
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 774 times.
798 if(version > 0x192)
19024 {
19025 //section version info
19026
1/2
✓ Branch 0 taken 774 times.
✗ Branch 1 not taken.
774 if(!p_igetw(&section_version,f))
19027 {
19028 delete[] temp_tile;
19029 return qe_invalid;
19030 }
19031
19032 774 FFCore.quest_format[vTiles] = section_version;
19033
19034
1/2
✓ Branch 0 taken 774 times.
✗ Branch 1 not taken.
774 if(!read_deprecated_section_cversion(f))
19035 {
19036 delete[] temp_tile;
19037 return qe_invalid;
19038 }
19039
19040 //section size
19041
1/2
✓ Branch 0 taken 774 times.
✗ Branch 1 not taken.
774 if(!p_igetl(&section_size,f))
19042 {
19043 delete[] temp_tile;
19044 return qe_invalid;
19045 }
19046 774 }
19047
19048 //if ( build < 41 )
19049 //{
19050 // tiles_used = ZC250MAXTILES;
19051 //}
19052
19053
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 798 times.
798 if(version < 0x174)
19054 {
19055 tiles_used=TILES_PER_PAGE*4;
19056 } //no expanded tile space
19057
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 780 times.
798 else if(version < 0x191)
19058 {
19059 18 tiles_used=OLDMAXTILES;
19060 18 }
19061 else
19062 {
19063 //finally... section data
19064
3/4
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 590 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 190 times.
780 if ( version >= 0x254 && build >= 41 ) //read and write the size of tiles_used properly
19065 {
19066
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if(!p_igetl(&tiles_used,f))
19067 {
19068 delete[] temp_tile;
19069 return qe_invalid;
19070 }
19071 190 }
19072 else
19073 {
19074
1/2
✓ Branch 0 taken 590 times.
✗ Branch 1 not taken.
590 if(!p_igetw(&tiles_used,f))
19075 {
19076 delete[] temp_tile;
19077 return qe_invalid;
19078 }
19079 }
19080 }
19081
19082
1/2
✓ Branch 0 taken 798 times.
✗ Branch 1 not taken.
798 tiles_used=zc_min(tiles_used, max_tiles);
19083
19084 //if ( version < 0x254 || ( version >= 0x254 && build < 41 )) //don't do this, it crashes ZQuest. -Z
19085 //if ( version < 0x254 && build < 41 )
19086
3/6
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 608 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 190 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
798 if ( version < 0x254 || (version == 0x254 && build < 41) )
19087 //if ( build < 41 )
19088 {
19089
1/2
✓ Branch 0 taken 608 times.
✗ Branch 1 not taken.
608 tiles_used=zc_min(tiles_used, ZC250MAXTILES-start_tile);
19090 608 }
19091 else //2.55
19092 {
19093
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 tiles_used = zc_min(tiles_used,NEWMAXTILES-start_tile);
19094 }
19095
19096 //if ( section_version > 1 ) tiles_used = NEWMAXTILES;
19097
19098
19099
2/2
✓ Branch 0 taken 18443029 times.
✓ Branch 1 taken 798 times.
18443827 for(int32_t i=0; i<tiles_used; ++i)
19100 {
19101 18443029 byte format=tf4Bit;
19102 18443029 memset(temp_tile, 0, tilesize(tf32Bit));
19103
19104
3/6
✓ Branch 0 taken 2985456 times.
✓ Branch 1 taken 15457573 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2985456 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
18443029 if((version>0x211)||((version==0x211)&&(build>4)))
19105 {
19106
1/2
✓ Branch 0 taken 15457573 times.
✗ Branch 1 not taken.
15457573 if(!p_getc(&format,f))
19107 {
19108 delete[] temp_tile;
19109 return qe_invalid;
19110 }
19111 15457573 }
19112
4/4
✓ Branch 0 taken 7250572 times.
✓ Branch 1 taken 11192457 times.
✓ Branch 2 taken 3319860 times.
✓ Branch 3 taken 3930712 times.
18443029 if(section_version > 2 && !format)
19113 {
19114 3930712 reset_tile(buf,start_tile+i,tf4Bit);
19115 3930712 continue;
19116 }
19117
19118
2/2
✓ Branch 0 taken 14020107 times.
✓ Branch 1 taken 492210 times.
14512317 int size = format == tf4Bit ? 128 : tilesize(format);
19119
1/2
✓ Branch 0 taken 14512317 times.
✗ Branch 1 not taken.
14512317 if(!pfread(temp_tile,size,f))
19120 {
19121 delete[] temp_tile;
19122 return qe_invalid;
19123 }
19124
19125
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14512317 times.
14512317 if (should_skip)
19126 continue;
19127
19128 14512317 buf[start_tile+i].format=format;
19129
19130
2/2
✓ Branch 0 taken 14308432 times.
✓ Branch 1 taken 203885 times.
14512317 if(buf[start_tile+i].data)
19131 {
19132 14308432 free(buf[start_tile+i].data);
19133 14308432 buf[start_tile+i].data=NULL;
19134 14308432 }
19135
19136 14512317 buf[start_tile+i].data=(byte *)malloc(tilesize(buf[start_tile+i].format));
19137
19138
2/2
✓ Branch 0 taken 14020107 times.
✓ Branch 1 taken 492210 times.
14512317 if (format == tf4Bit)
19139 {
19140 byte temp[256];
19141 14020107 byte *si = temp_tile + 128;
19142 14020107 byte *di = temp + 256;
19143
19144
2/2
✓ Branch 0 taken 1794573696 times.
✓ Branch 1 taken 14020107 times.
1808593803 for(int i=127; i>=0; --i)
19145 {
19146 1794573696 (*(--di)) = (*(--si)) >> 4;
19147 1794573696 (*(--di)) = (*si) & 15;
19148 1794573696 }
19149
19150 14020107 memcpy(buf[start_tile+i].data,temp,256);
19151 14020107 }
19152 else
19153 {
19154 492210 memcpy(buf[start_tile+i].data,temp_tile,tilesize(buf[start_tile+i].format));
19155 }
19156 14512317 }
19157 }
19158
19159
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 798 times.
798 if (should_skip)
19160 return 0;
19161
19162
2/2
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 608 times.
798 if ( section_version < 2 ) //write blank tile data --check s_version with this again instead?
19163 {
19164
2/2
✓ Branch 0 taken 90579840 times.
✓ Branch 1 taken 608 times.
90580448 for ( int32_t q = ZC250MAXTILES; q < NEWMAXTILES; ++q )
19165 {
19166
19167 //memcpy(buf[q].data,temp_tile,tilesize(buf[q].format));
19168 90579840 reset_tile(buf,q,tf4Bit);
19169
19170
19171 /*
19172
19173 byte tempbyte;
19174 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19175 {
19176 tempbyte=buf[ZC250MAXTILES-1].data[i];
19177 buf[q].data[i] = tempbyte;
19178 }
19179 //int32_t temp = tempbyte=buf[130].data[i];
19180 //buf[q].data = buf[ZC250MAXTILES-1].data;
19181 */
19182 //reset_tile(buf,q,tf4Bit);
19183 90579840 }
19184
19185 608 }
19186
19187
4/6
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 608 times.
✓ Branch 2 taken 190 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 190 times.
798 if ( version < 0x254 || ( version >= 0x254 && build < 41 ))
19188 {
19189
2/2
✓ Branch 0 taken 30111299 times.
✓ Branch 1 taken 608 times.
30111907 for(int32_t i=start_tile+tiles_used; i<max_tiles; ++i)
19190 {
19191 30111299 reset_tile(buf,i,tf4Bit);
19192 30111299 }
19193 608 }
19194 else
19195 {
19196
2/2
✓ Branch 0 taken 32930712 times.
✓ Branch 1 taken 190 times.
32930902 for(int32_t i=start_tile+tiles_used; i<max_tiles; ++i)
19197 {
19198 32930712 reset_tile(buf,i,tf4Bit);
19199 32930712 }
19200 }
19201
19202
5/6
✓ Branch 0 taken 780 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 774 times.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
798 if((version < 0x192)|| ((version == 0x192)&&(build<186)))
19203 {
19204
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 6 times.
24 if(get_qr(qr_BSZELDA)) //
19205 {
19206 byte tempbyte;
19207 6 int32_t floattile=wpnsbuf[iwSwim].tile;
19208
19209
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 6 times.
1542 for(int32_t i=0; i<tilesize(tf4Bit); i++) //BSZelda tiles are out of order //does this include swim tiles?
19210 {
19211 1536 tempbyte=buf[23].data[i];
19212 1536 buf[23].data[i]=buf[24].data[i];
19213 1536 buf[24].data[i]=buf[25].data[i];
19214 1536 buf[25].data[i]=buf[26].data[i];
19215 1536 buf[26].data[i]=tempbyte;
19216 1536 }
19217 //swim tiles are out of order, too, but nobody cared? -Z
19218
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 6 times.
1542 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19219 {
19220 1536 tempbyte=buf[floattile+11].data[i];
19221 1536 buf[floattile+11].data[i]=buf[floattile+12].data[i];
19222 1536 buf[floattile+12].data[i]=tempbyte;
19223 1536 }
19224 6 }
19225 24 }
19226
19227
3/6
✓ Branch 0 taken 715 times.
✓ Branch 1 taken 83 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 715 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
798 if((version < 0x211)||((version == 0x211)&&(build<7))) //Goriya tiles are out of order
19228 {
19229
2/2
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 22 times.
83 if(!get_qr(qr_NEWENEMYTILES))
19230 {
19231 byte tempbyte;
19232
19233
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 22 times.
5654 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19234 {
19235 5632 tempbyte=buf[130].data[i];
19236 5632 buf[130].data[i]=buf[132].data[i];
19237 5632 buf[132].data[i]=tempbyte;
19238
19239 5632 tempbyte=buf[131].data[i];
19240 5632 buf[131].data[i]=buf[133].data[i];
19241 5632 buf[133].data[i]=tempbyte;
19242 5632 }
19243 22 }
19244 83 }
19245
19246 798 al_trace("Registering blank tiles\n");
19247 798 register_blank_tiles();
19248
19249 //memset(temp_tile, 0, tilesize(tf32Bit));
19250
1/2
✓ Branch 0 taken 798 times.
✗ Branch 1 not taken.
798 delete[] temp_tile;
19251 798 temp_tile=NULL;
19252 798 return 0;
19253 798 }
19254
19255 477 int32_t readtunes(PACKFILE *f, zquestheader *Header, zctune *tunes /*zcmidi_ *midis*/)
19256 {
19257
2/2
✓ Branch 0 taken 454 times.
✓ Branch 1 taken 23 times.
477 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_midis);
19258
19259 static byte fake_midi_flags[32];
19260
19261
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 477 times.
477 byte *mf=should_skip ? fake_midi_flags : midi_flags;
19262 int32_t dummy;
19263 word dummy2;
19264 // zcmidi_ temp_midi;
19265 int32_t tunes_to_read;
19266 477 int32_t tune_count=0;
19267 477 word section_version=0;
19268 477 zctune temp;
19269
19270
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 454 times.
477 if(Header->zelda_version < 0x193)
19271 {
19272 // mf=Header->data_flags+ZQ_MIDIS2;
19273
5/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 1 times.
23 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<178)))
19274 {
19275 22 tunes_to_read=MAXCUSTOMMIDIS192b177;
19276 22 }
19277 else
19278 {
19279 1 tunes_to_read=MAXCUSTOMTUNES;
19280 }
19281 23 }
19282 else
19283 {
19284 //section version info
19285
1/2
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
454 if(!p_igetw(&section_version,f))
19286 {
19287 return qe_invalid;
19288 }
19289
19290
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 454 times.
454 if (!should_skip)
19291 454 FFCore.quest_format[vMIDIs] = section_version;
19292
19293
1/2
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
454 if(!p_igetw(&dummy2,f))
19294 {
19295 return qe_invalid;
19296 }
19297
19298 //section size
19299
1/2
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
454 if(!p_igetl(&dummy,f))
19300 {
19301 return qe_invalid;
19302 }
19303
19304 //finally... section data
19305
1/2
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
454 if(!pfread(midi_flags,sizeof(midi_flags),f))
19306 {
19307 return qe_invalid;
19308 }
19309
19310 454 tunes_to_read=MAXCUSTOMTUNES;
19311 }
19312
19313
2/2
✓ Branch 0 taken 120204 times.
✓ Branch 1 taken 477 times.
120681 for(int32_t i=0; i<MAXCUSTOMTUNES; ++i)
19314 {
19315
2/2
✓ Branch 0 taken 10260 times.
✓ Branch 1 taken 109944 times.
120204 if(get_bit(mf, i))
19316 {
19317 10260 ++tune_count;
19318 10260 }
19319 120204 }
19320
19321
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 477 times.
477 if (!should_skip)
19322 477 reset_tunes(tunes); //reset_midis(midis);
19323
19324
2/2
✓ Branch 0 taken 115364 times.
✓ Branch 1 taken 477 times.
115841 for(int32_t i=0; i<tunes_to_read; i++)
19325 {
19326 115364 temp.clear(); //memset(&temp_midi,0,sizeof(zcmidi_));
19327
19328
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115364 times.
115364 if (!should_skip)
19329 115364 tunes[i].reset(); // reset_midi(midis+i);
19330
19331
2/2
✓ Branch 0 taken 105104 times.
✓ Branch 1 taken 10260 times.
115364 if(get_bit(mf,i))
19332 {
19333
2/2
✓ Branch 0 taken 2663 times.
✓ Branch 1 taken 7597 times.
10260 if(section_version < 4)
19334 {
19335
1/2
✓ Branch 0 taken 2663 times.
✗ Branch 1 not taken.
2663 if(!p_getstr(temp.title,20,f))
19336 {
19337 return qe_invalid;
19338 }
19339 2663 }
19340 else
19341 {
19342
1/2
✓ Branch 0 taken 7597 times.
✗ Branch 1 not taken.
7597 if(!p_getstr(temp.title,sizeof(temp.title)-1,f))
19343 {
19344 return qe_invalid;
19345 }
19346 }
19347
19348
1/2
✓ Branch 0 taken 10260 times.
✗ Branch 1 not taken.
10260 if(!p_igetl(&temp.start,f))
19349 {
19350 return qe_invalid;
19351 }
19352
19353
1/2
✓ Branch 0 taken 10260 times.
✗ Branch 1 not taken.
10260 if(!p_igetl(&temp.loop_start,f))
19354 {
19355 return qe_invalid;
19356 }
19357
19358
1/2
✓ Branch 0 taken 10260 times.
✗ Branch 1 not taken.
10260 if(!p_igetl(&temp.loop_end,f))
19359 {
19360 return qe_invalid;
19361 }
19362
19363
1/2
✓ Branch 0 taken 10260 times.
✗ Branch 1 not taken.
10260 if(!p_igetw(&temp.loop,f))
19364 {
19365 return qe_invalid;
19366 }
19367
19368
1/2
✓ Branch 0 taken 10260 times.
✗ Branch 1 not taken.
10260 if(!p_igetw(&temp.volume,f))
19369 {
19370 return qe_invalid;
19371 }
19372
19373
2/2
✓ Branch 0 taken 10011 times.
✓ Branch 1 taken 249 times.
10260 if(Header->zelda_version < 0x193)
19374 {
19375
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if(!p_igetl(&dummy,f))
19376 {
19377 return qe_invalid;
19378 }
19379 249 }
19380
19381
2/2
✓ Branch 0 taken 2663 times.
✓ Branch 1 taken 7597 times.
10260 if(section_version >= 3)
19382 {
19383
1/2
✓ Branch 0 taken 7597 times.
✗ Branch 1 not taken.
7597 if(!pfread(&temp.flags,sizeof(temp.flags),f))
19384 {
19385 return qe_invalid;
19386 }
19387 7597 }
19388
19389
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10260 times.
10260 if (!should_skip)
19390 10260 tunes[i].copyfrom(temp); // memcpy(&midis[i], &temp_midi, sizeof(zcmidi_));
19391
19392
2/2
✓ Branch 0 taken 2663 times.
✓ Branch 1 taken 7597 times.
10260 if(section_version < 2) //= 1 || (Header->zelda_version < 0x211) || (Header->zelda_version == 0x211 && Header->build < 18))
19393 {
19394
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2663 times.
2663 if (should_skip)
19395 {
19396 if (read_midi(f)==NULL)
19397 {
19398 return qe_invalid;
19399 }
19400
19401 continue;
19402 }
19403
19404 // old format - a midi is a midi
19405
1/2
✓ Branch 0 taken 2663 times.
✗ Branch 1 not taken.
2663 if((tunes[i].data=read_midi(f))==NULL)
19406 {
19407 return qe_invalid;
19408 }
19409 2663 }
19410 else
19411 {
19412 byte format;
19413
1/2
✓ Branch 0 taken 7597 times.
✗ Branch 1 not taken.
7597 if(!pfread(&format,sizeof(format),f))
19414 {
19415 return qe_invalid;
19416 }
19417
19418 // MIDI is the only format saved here.
19419 // Never did more than MIDI for a zctune, and no plans to now.
19420
1/2
✓ Branch 0 taken 7597 times.
✗ Branch 1 not taken.
7597 if (format != MFORMAT_MIDI)
19421 {
19422 return qe_invalid;
19423 }
19424
19425 7597 tunes[i].data = read_midi(f);
19426
1/2
✓ Branch 0 taken 7597 times.
✗ Branch 1 not taken.
7597 if (!tunes[i].data)
19427 {
19428 return qe_invalid;
19429 }
19430 }
19431 10260 }
19432 115364 }
19433
19434 477 return 0;
19435 477 }
19436
19437 477 int32_t readcheatcodes(PACKFILE *f, zquestheader *Header)
19438 {
19439
2/2
✓ Branch 0 taken 454 times.
✓ Branch 1 taken 23 times.
477 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_cheats);
19440
19441 int32_t dummy;
19442 ZCHEATS tempzcheats;
19443 477 char temp_use_cheats=1;
19444 477 memset(&tempzcheats, 0, sizeof(tempzcheats));
19445 477 word s_version = 0;
19446
19447
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 454 times.
477 if(Header->zelda_version > 0x192)
19448 {
19449 //section version info
19450
1/2
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
454 if(!p_igetw(&s_version,f))
19451 {
19452 return qe_invalid;
19453 }
19454
19455 454 FFCore.quest_format[vCheats] = s_version;
19456
1/2
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
454 if(!p_igetw(&dummy,f))
19457 {
19458 return qe_invalid;
19459 }
19460
19461 //section size
19462
1/2
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
454 if(!p_igetl(&dummy,f))
19463 {
19464 return qe_invalid;
19465 }
19466
19467 //finally... section data
19468
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 454 times.
454 if(!p_getc(&temp_use_cheats,f))
19469 {
19470 return qe_invalid;
19471 }
19472 454 }
19473
19474
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 477 times.
477 if(Header->data_flags[ZQ_CHEATS2])
19475 {
19476
1/2
✓ Branch 0 taken 477 times.
✗ Branch 1 not taken.
477 if(!p_igetl(&tempzcheats.flags,f))
19477 {
19478 return qe_invalid;
19479 }
19480
19481
1/2
✓ Branch 0 taken 477 times.
✗ Branch 1 not taken.
477 if(!pfread(&tempzcheats.codes, sizeof(tempzcheats.codes),f))
19482 {
19483 return qe_invalid;
19484 }
19485 477 }
19486
19487
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 477 times.
477 if (should_skip)
19488 return 0;
19489
19490 477 memcpy(&zcheats, &tempzcheats, sizeof(tempzcheats));
19491 477 Header->data_flags[ZQ_CHEATS2]=temp_use_cheats;
19492
19493 477 return 0;
19494 477 }
19495
19496 304 int32_t readinitdata_old(PACKFILE *f, zquestheader *Header, word s_version, zinitdata& temp_zinit)
19497 {
19498
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 281 times.
304 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_initdata);
19499
19500 byte padding, tempbyte;
19501
19502 // Legacy item properties (now integrated into itemdata)
19503 byte sword_hearts[4];
19504 byte beam_hearts[4];
19505 304 byte beam_percent=0;
19506 word beam_power[4];
19507 304 byte hookshot_length=99;
19508 304 byte hookshot_links=100;
19509 304 byte longshot_length=99;
19510 304 byte longshot_links=100;
19511 304 byte moving_fairy_hearts=3;
19512 304 byte moving_fairy_heart_percent=0;
19513 304 byte stationary_fairy_hearts=3;
19514 304 byte stationary_fairy_heart_percent=0;
19515 304 byte moving_fairy_magic=0;
19516 304 byte moving_fairy_magic_percent=0;
19517 304 byte stationary_fairy_magic=0;
19518 304 byte stationary_fairy_magic_percent=0;
19519 304 byte blue_potion_hearts=100;
19520 304 byte blue_potion_heart_percent=1;
19521 304 byte red_potion_hearts=100;
19522 304 byte red_potion_heart_percent=1;
19523 304 byte blue_potion_magic=100;
19524 304 byte blue_potion_magic_percent=1;
19525 304 byte red_potion_magic=100;
19526 304 byte red_potion_magic_percent=1;
19527
19528 304 byte bomb_ratio = 4;
19529
19530 304 subscr_mode = 0;
19531
19532 /* HIGHLY UNORTHODOX UPDATING THING, by L
19533 * This fixes quests made before revision 277 (such as the 'Lost Isle Build'),
19534 * where the speed of Pols Voice changed. It also coincided with V_INITDATA
19535 * changing from 13 to 14.
19536 */
19537
2/2
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 82 times.
304 if(s_version < 14)
19538 82 fixpolsvoice=true;
19539
19540 /* End highly unorthodox updating thing */
19541
19542
4/4
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 108 times.
✓ Branch 3 taken 114 times.
304 if(s_version >= 15 && get_bit(deprecated_rules, 27)) // The int16_t-lived rule, qr_JUMPHEROLAYER3
19543 114 temp_zinit.jump_hero_layer_threshold=0;
19544
19545
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 222 times.
304 if(s_version >= 10)
19546 {
19547 char temp;
19548
19549 //new-style items
19550
2/2
✓ Branch 0 taken 56832 times.
✓ Branch 1 taken 222 times.
57054 for(int32_t j=0; j<256; j++)
19551 {
19552
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56832 times.
56832 if(!p_getc(&temp,f))
19553 return qe_invalid;
19554
19555 56832 temp_zinit.set_item(j, temp != 0);
19556 56832 }
19557 222 }
19558
19559
5/6
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 281 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 18 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
304 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>26)))
19560 {
19561 char temp;
19562
19563 //finally... section data
19564
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 281 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
291 if((Header->zelda_version > 0x192)||
19565 //new only
19566
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19567 {
19568 //OLD-style items... sigh
19569
2/2
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 60 times.
282 if(s_version < 10)
19570 {
19571
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19572 {
19573 return qe_invalid;
19574 }
19575
19576 60 temp_zinit.set_item(iRaft, temp != 0);
19577
19578
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19579 {
19580 return qe_invalid;
19581 }
19582
19583 60 temp_zinit.set_item(iLadder, temp != 0);
19584
19585
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19586 {
19587 return qe_invalid;
19588 }
19589
19590 60 temp_zinit.set_item(iBook, temp != 0);
19591
19592
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19593 {
19594 return qe_invalid;
19595 }
19596
19597 60 temp_zinit.set_item(iMKey, temp != 0);
19598
19599
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19600 {
19601 return qe_invalid;
19602 }
19603
19604 60 temp_zinit.set_item(iFlippers, temp != 0);
19605
19606
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19607 {
19608 return qe_invalid;
19609 }
19610
19611 60 temp_zinit.set_item(iBoots, temp != 0);
19612 60 }
19613 282 }
19614
19615
2/2
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 64 times.
286 if(s_version < 10)
19616 {
19617 char tempring, tempsword, tempshield, tempwallet, tempbracelet, tempamulet, tempbow;
19618
19619
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempring,f))
19620 {
19621 return qe_invalid;
19622 }
19623
19624
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempsword,f))
19625 {
19626 return qe_invalid;
19627 }
19628
19629
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempshield,f))
19630 {
19631 return qe_invalid;
19632 }
19633
19634
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempwallet,f))
19635 {
19636 return qe_invalid;
19637 }
19638
19639
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempbracelet,f))
19640 {
19641 return qe_invalid;
19642 }
19643
19644
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempamulet,f))
19645 {
19646 return qe_invalid;
19647 }
19648
19649
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempbow,f))
19650 {
19651 return qe_invalid;
19652 }
19653
19654 //old only
19655
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
64 if((Header->zelda_version == 0x192)&&(Header->build<174))
19656 {
19657
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempring=(tempring)?(1<<(tempring-1)):0;
19658
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempsword=(tempsword)?(1<<(tempsword-1)):0;
19659
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 tempshield=(tempshield)?(1<<(tempshield-1)):0;
19660
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempwallet=(tempwallet)?(1<<(tempwallet-1)):0;
19661
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempbracelet=(tempbracelet)?(1<<(tempbracelet-1)):0;
19662
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempamulet=(tempamulet)?(1<<(tempamulet-1)):0;
19663
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempbow=(tempbow)?(1<<(tempbow-1)):0;
19664 4 }
19665
19666 //rings start at level 2... wtf
19667 //account for this -DD
19668 64 tempring <<= 1;
19669 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_ring, tempring);
19670 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_sword, tempsword);
19671 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_shield, tempshield);
19672 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_wallet, tempwallet);
19673 //bracelet ALSO starts at level 2 :-( -DD
19674 64 tempbracelet<<=1;
19675 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bracelet, tempbracelet);
19676 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_amulet, tempamulet);
19677 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bow, tempbow);
19678
19679 //new only
19680
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 1 times.
64 if((Header->zelda_version == 0x192)&&(Header->build>173))
19681 {
19682
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 1 times.
33 for(int32_t q=0; q<32; q++)
19683 {
19684
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 if(!p_getc(&padding,f))
19685 {
19686 return qe_invalid;
19687 }
19688 32 }
19689 1 }
19690
19691 char tempcandle, tempboomerang, temparrow, tempwhistle;
19692
19693
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempcandle,f))
19694 {
19695 return qe_invalid;
19696 }
19697
19698
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempboomerang,f))
19699 {
19700 return qe_invalid;
19701 }
19702
19703
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&temparrow,f))
19704 {
19705 return qe_invalid;
19706 }
19707
19708
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&temp,f))
19709 {
19710 return qe_invalid;
19711 }
19712
19713 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_potion, temp);
19714
19715
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempwhistle,f))
19716 {
19717 return qe_invalid;
19718 }
19719
19720 //old only
19721
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
64 if((Header->zelda_version == 0x192)&&(Header->build<174))
19722 {
19723
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempcandle=(tempcandle)?(1<<(tempcandle-1)):0;
19724
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempboomerang=(tempboomerang)?(1<<(tempboomerang-1)):0;
19725
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 temparrow=(temparrow)?(1<<(temparrow-1)):0;
19726
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempwhistle=(tempwhistle)?(1<<(tempwhistle-1)):0;
19727 4 }
19728
19729 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_candle, tempcandle);
19730 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_brang, tempboomerang);
19731 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_arrow, temparrow);
19732 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_whistle, tempwhistle);
19733 //What about the potion...?
19734
19735 64 }
19736
19737
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 269 times.
286 if(s_version < 29)
19738 {
19739 //Oh sure, stick these IN THE MIDDLE OF THE ITEMS, just to make me want
19740 //to jab out my eye...
19741
1/2
✓ Branch 0 taken 269 times.
✗ Branch 1 not taken.
269 if(!p_getc(&padding,f))
19742 return qe_invalid;
19743 269 temp_zinit.counter[crBOMBS] = padding;
19744
19745
1/2
✓ Branch 0 taken 269 times.
✗ Branch 1 not taken.
269 if(!p_getc(&padding,f))
19746 return qe_invalid;
19747 269 temp_zinit.counter[crSBOMBS] = padding;
19748 269 }
19749
19750 //Back to more OLD item code
19751
2/2
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 64 times.
286 if(s_version < 10)
19752 {
19753
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
69 if((Header->zelda_version > 0x192)||
19754 //new only
19755
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19756 {
19757
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19758 {
19759 return qe_invalid;
19760 }
19761
19762 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_wand, temp);
19763
19764
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19765 {
19766 return qe_invalid;
19767 }
19768
19769 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_letter, temp);
19770
19771
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19772 {
19773 return qe_invalid;
19774 }
19775
19776 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_lens, temp);
19777
19778
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19779 {
19780 return qe_invalid;
19781 }
19782
19783 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_hookshot, temp);
19784
19785
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19786 {
19787 return qe_invalid;
19788 }
19789
19790 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bait, temp);
19791
19792
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19793 {
19794 return qe_invalid;
19795 }
19796
19797 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_hammer, temp);
19798
19799
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19800 {
19801 return qe_invalid;
19802 }
19803
19804 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divinefire, temp);
19805
19806
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19807 {
19808 return qe_invalid;
19809 }
19810
19811 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divineescape, temp);
19812
19813
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19814 {
19815 return qe_invalid;
19816 }
19817
19818 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divineprotection, temp);
19819
19820
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19821 {
19822 return qe_invalid;
19823 }
19824
19825
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 1 times.
60 if(Header->zelda_version == 0x192)
19826 {
19827
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 1 times.
33 for(int32_t q=0; q<32; q++)
19828 {
19829
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 if(!p_getc(&padding,f))
19830 {
19831 return qe_invalid;
19832 }
19833 32 }
19834 1 }
19835 60 }
19836 64 }
19837
19838 //old only
19839
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 281 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
286 if((Header->zelda_version == 0x192)&&(Header->build<174))
19840 {
19841 byte equipment, tmpitm; //bit flags
19842
19843
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&equipment,f))
19844 {
19845 return qe_invalid;
19846 }
19847
19848 4 temp_zinit.set_item(iRaft, get_bit(&equipment, idE_RAFT)!=0);
19849 4 temp_zinit.set_item(iLadder, get_bit(&equipment, idE_LADDER)!=0);
19850 4 temp_zinit.set_item(iBook, get_bit(&equipment, idE_BOOK)!=0);
19851 4 temp_zinit.set_item(iMKey, get_bit(&equipment, idE_KEY)!=0);
19852 4 temp_zinit.set_item(iFlippers, get_bit(&equipment, idE_FLIPPERS)!=0);
19853 4 temp_zinit.set_item(iBoots, get_bit(&equipment, idE_BOOTS)!=0);
19854
19855
19856
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tmpitm,f))
19857 {
19858 return qe_invalid;
19859 }
19860
19861 4 temp_zinit.set_item(iWand, get_bit(&tmpitm, idI_WAND)!=0);
19862 4 temp_zinit.set_item(iLetter, get_bit(&tmpitm, idI_LETTER)!=0);
19863 4 temp_zinit.set_item(iLens, get_bit(&tmpitm, idI_LENS)!=0);
19864 4 temp_zinit.set_item(iHookshot, get_bit(&tmpitm, idI_HOOKSHOT)!=0);
19865 4 temp_zinit.set_item(iBait, get_bit(&tmpitm, idI_BAIT)!=0);
19866 4 temp_zinit.set_item(iHammer, get_bit(&tmpitm, idI_HAMMER)!=0);
19867 4 }
19868
19869
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 if(!p_getc(&tempbyte,f))
19870 return qe_invalid;
19871 286 temp_zinit.mcounter[crLIFE] = tempbyte;
19872
19873
19874
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 222 times.
286 if(s_version < 14)
19875 {
19876 byte temphp;
19877
19878
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&temphp,f))
19879 {
19880 return qe_invalid;
19881 }
19882
19883 64 temp_zinit.counter[crLIFE]=temphp;
19884
19885
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&temphp,f))
19886 {
19887 return qe_invalid;
19888 }
19889
19890 64 temp_zinit.cont_heart=temphp;
19891 64 }
19892 else
19893 {
19894
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_igetw(&temp_zinit.counter[crLIFE],f))
19895 {
19896 return qe_invalid;
19897 }
19898
19899
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_igetw(&temp_zinit.cont_heart,f))
19900 {
19901 return qe_invalid;
19902 }
19903 }
19904
19905
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 if(!p_getc(&temp_zinit.hcp,f))
19906 {
19907 return qe_invalid;
19908 }
19909
19910
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 222 times.
286 if(s_version >= 14)
19911 {
19912
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_getc(&temp_zinit.hcp_per_hc,f))
19913 {
19914 return qe_invalid;
19915 }
19916
19917
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(s_version<16) // July 2007
19918 {
19919 if(get_qr(qr_BRANGPICKUP+1))
19920 temp_zinit.hcp_per_hc = 0xFF;
19921
19922 //Dispose of legacy rule
19923 set_qr(qr_BRANGPICKUP+1, 0);
19924 }
19925 222 }
19926
19927
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 269 times.
286 if(s_version < 29)
19928 {
19929
1/2
✓ Branch 0 taken 269 times.
✗ Branch 1 not taken.
269 if(!p_getc(&padding,f))
19930 return qe_invalid;
19931 269 temp_zinit.mcounter[crBOMBS] = padding;
19932 269 }
19933
19934
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 if(!p_getc(&temp_zinit.counter[crKEYS],f))
19935 {
19936 return qe_invalid;
19937 }
19938
19939
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 if(!p_igetw(&temp_zinit.counter[crMONEY],f))
19940 {
19941 return qe_invalid;
19942 }
19943
19944
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 if(!p_getc(&tempbyte,f))
19945 return qe_invalid;
19946
2/2
✓ Branch 0 taken 2288 times.
✓ Branch 1 taken 286 times.
2574 for(int q = 0; q < 8; ++q)
19947
2/2
✓ Branch 0 taken 504 times.
✓ Branch 1 taken 1784 times.
2288 SETFLAG(temp_zinit.litems[q+1], liTRIFORCE, get_bitl(tempbyte, q));
19948
19949 286 int level_count = 32;
19950
3/6
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 222 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 64 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
286 if(s_version>12 || (Header->zelda_version == 0x211 && Header->build == 18))
19951 222 level_count = 64;
19952 byte tmp_map[64];
19953 byte tmp_compass[64];
19954
2/2
✓ Branch 0 taken 16256 times.
✓ Branch 1 taken 286 times.
16542 for(int32_t i=0; i<level_count; i++)
19955
1/2
✓ Branch 0 taken 16256 times.
✗ Branch 1 not taken.
16256 if(!p_getc(&tmp_map[i],f))
19956 return qe_invalid;
19957
2/2
✓ Branch 0 taken 16256 times.
✓ Branch 1 taken 286 times.
16542 for(int32_t i=0; i<level_count; i++)
19958
1/2
✓ Branch 0 taken 16256 times.
✗ Branch 1 not taken.
16256 if(!p_getc(&tmp_compass[i],f))
19959 return qe_invalid;
19960
2/2
✓ Branch 0 taken 130048 times.
✓ Branch 1 taken 286 times.
130334 for(int q = 0; q < level_count*8; ++q)
19961 {
19962
2/2
✓ Branch 0 taken 796 times.
✓ Branch 1 taken 129252 times.
130048 SETFLAG(temp_zinit.litems[q], liMAP, get_bit(tmp_map, q));
19963
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 130039 times.
130048 SETFLAG(temp_zinit.litems[q], liCOMPASS, get_bit(tmp_compass, q));
19964 130048 }
19965
19966
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 281 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
291 if((Header->zelda_version > 0x192)||
19967 //new only
19968
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19969 {
19970 byte tmp_boss_key[64];
19971
2/2
✓ Branch 0 taken 16128 times.
✓ Branch 1 taken 282 times.
16410 for(int32_t i=0; i<level_count; i++)
19972 {
19973
1/2
✓ Branch 0 taken 16128 times.
✗ Branch 1 not taken.
16128 if(!p_getc(&tmp_boss_key[i],f))
19974 {
19975 return qe_invalid;
19976 }
19977 16128 }
19978
2/2
✓ Branch 0 taken 129024 times.
✓ Branch 1 taken 282 times.
129306 for(int q = 0; q < level_count*8; ++q)
19979 {
19980
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129024 times.
129024 SETFLAG(temp_zinit.litems[q], liBOSSKEY, get_bit(tmp_boss_key, q));
19981 129024 }
19982 282 }
19983
19984 byte tmpmisc[16];
19985
2/2
✓ Branch 0 taken 4576 times.
✓ Branch 1 taken 286 times.
4862 for(int32_t i=0; i<16; i++)
19986
1/2
✓ Branch 0 taken 4576 times.
✗ Branch 1 not taken.
4576 if(!p_getc(&tmpmisc[i],f))
19987 return qe_invalid;
19988 286 temp_zinit.flags.set(INIT_FL_CONTPERCENT,get_bit(tmpmisc,0));
19989 286 temp_zinit.magicdrainrate = get_bit(tmpmisc,1) ? 1 : 2; //Double Magic flag
19990 286 temp_zinit.flags.set(INIT_FL_CANSLASH,get_bit(tmpmisc,2));
19991
19992
4/4
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 256 times.
✓ Branch 3 taken 64 times.
542 if(s_version < 15) for(int32_t i=0; i<4; i++)
19993
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(!p_getc(&sword_hearts[i],f))
19994 64 return qe_invalid;
19995
19996
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 if(!p_getc(&temp_zinit.last_map,f))
19997 {
19998 return qe_invalid;
19999 }
20000
20001
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 if(!p_getc(&temp_zinit.last_screen,f))
20002 {
20003 return qe_invalid;
20004 }
20005
20006
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 222 times.
286 if(s_version < 14)
20007 {
20008 byte tempmp;
20009
20010
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempmp,f))
20011 {
20012 return qe_invalid;
20013 }
20014
20015 64 temp_zinit.mcounter[crMAGIC]=tempmp;
20016
20017
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempmp,f))
20018 {
20019 return qe_invalid;
20020 }
20021
20022 64 temp_zinit.counter[crMAGIC]=tempmp;
20023 64 }
20024 else
20025 {
20026
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_igetw(&temp_zinit.mcounter[crMAGIC],f))
20027 {
20028 return qe_invalid;
20029 }
20030
20031
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_igetw(&temp_zinit.counter[crMAGIC],f))
20032 {
20033 return qe_invalid;
20034 }
20035 }
20036
20037
20038
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 222 times.
286 if(s_version < 15)
20039 {
20040
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
64 if(s_version < 12)
20041 {
20042 64 temp_zinit.mcounter[crMAGIC]*=32;
20043 64 temp_zinit.counter[crMAGIC]*=32;
20044 64 }
20045
20046
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 64 times.
320 for(int32_t i=0; i<4; i++)
20047 {
20048
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(!p_getc(&beam_hearts[i],f))
20049 {
20050 return qe_invalid;
20051 }
20052 256 }
20053
20054
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&beam_percent,f))
20055 {
20056 return qe_invalid;
20057 }
20058 64 }
20059 else
20060 {
20061
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_getc(&temp_zinit.bomb_ratio,f))
20062 return qe_invalid;
20063
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(temp_zinit.bomb_ratio < 1)
20064 temp_zinit.bomb_ratio = 1;
20065 222 else bomb_ratio = temp_zinit.bomb_ratio; //jank
20066 }
20067
20068
2/2
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 64 times.
286 if(s_version < 15)
20069 {
20070 byte tempbp;
20071
20072
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 64 times.
320 for(int32_t i=0; i<4; i++)
20073 {
20074
2/4
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 256 times.
✗ Branch 3 not taken.
256 if(!(s_version < 14 ? p_getc(&tempbp,f) : p_igetw(&tempbp,f)))
20075 {
20076 return qe_invalid;
20077 }
20078
20079 256 beam_power[i]=tempbp;
20080 256 }
20081
20082
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&hookshot_links,f))
20083 {
20084 return qe_invalid;
20085 }
20086
20087
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(s_version>6)
20088 {
20089 if(!p_getc(&hookshot_length,f))
20090 {
20091 return qe_invalid;
20092 }
20093
20094 if(!p_getc(&longshot_links,f))
20095 {
20096 return qe_invalid;
20097 }
20098
20099 if(!p_getc(&longshot_length,f))
20100 {
20101 return qe_invalid;
20102 }
20103 }
20104 64 }
20105
20106
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 if(!p_getc(&temp_zinit.msg_more_x,f))
20107 {
20108 return qe_invalid;
20109 }
20110
20111
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 if(!p_getc(&temp_zinit.msg_more_y,f))
20112 {
20113 return qe_invalid;
20114 }
20115
20116
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 if(!p_getc(&subscr_mode,f))
20117 return qe_invalid;
20118
20119 //old only
20120
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 281 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
286 if((Header->zelda_version == 0x192)&&(Header->build<174))
20121 {
20122 byte tmp_boss_key[32];
20123
2/2
✓ Branch 0 taken 128 times.
✓ Branch 1 taken 4 times.
132 for(int32_t i=0; i<32; i++)
20124 {
20125
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!p_getc(&tmp_boss_key[i],f))
20126 {
20127 return qe_invalid;
20128 }
20129 128 }
20130
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 4 times.
1028 for(int q = 0; q < 32*8; ++q)
20131 {
20132
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1024 times.
1024 SETFLAG(temp_zinit.litems[q], liBOSSKEY, get_bit(tmp_boss_key, q));
20133 1024 }
20134 4 }
20135
20136
5/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 281 times.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 4 times.
286 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>173))) //new only
20137 {
20138
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 222 times.
282 if(s_version <= 10)
20139 {
20140
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&tempbyte,f))
20141 {
20142 return qe_invalid;
20143 }
20144
20145 60 temp_zinit.start_dmap = (word)tempbyte;
20146 60 }
20147 else
20148 {
20149
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_igetw(&temp_zinit.start_dmap,f))
20150 {
20151 return qe_invalid;
20152 }
20153 }
20154
20155
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(!p_getc(&temp_zinit.heroAnimationStyle,f))
20156 {
20157 return qe_invalid;
20158 }
20159 282 }
20160
20161
4/4
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 17 times.
✓ Branch 3 taken 205 times.
286 if(s_version>1 && s_version < 29)
20162 {
20163
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 if(!p_getc(&padding,f))
20164 return qe_invalid;
20165 205 temp_zinit.counter[crARROWS] = padding;
20166
20167
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 if(!p_getc(&padding,f))
20168 return qe_invalid;
20169 205 temp_zinit.mcounter[crARROWS] = padding;
20170 205 }
20171
20172
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 222 times.
286 if(s_version>2)
20173 {
20174
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 222 times.
222 if(s_version <= 10)
20175 {
20176 for(int32_t i=0; i<OLDMAXLEVELS; i++)
20177 {
20178 if(!p_getc(&(temp_zinit.level_keys[i]),f))
20179 {
20180 return qe_invalid;
20181 }
20182 }
20183 }
20184 else
20185 {
20186
2/2
✓ Branch 0 taken 113664 times.
✓ Branch 1 taken 222 times.
113886 for(int32_t i=0; i<MAXLEVELS; i++)
20187 {
20188
1/2
✓ Branch 0 taken 113664 times.
✗ Branch 1 not taken.
113664 if(!p_getc(&(temp_zinit.level_keys[i]),f))
20189 {
20190 return qe_invalid;
20191 }
20192 113664 }
20193 }
20194 222 }
20195
20196
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 222 times.
286 if(s_version>3)
20197 {
20198
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_igetw(&temp_zinit.ss_grid_x,f))
20199 {
20200 return qe_invalid;
20201 }
20202
20203
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_igetw(&temp_zinit.ss_grid_y,f))
20204 {
20205 return qe_invalid;
20206 }
20207
20208
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_igetw(&temp_zinit.ss_grid_xofs,f))
20209 {
20210 return qe_invalid;
20211 }
20212
20213
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_igetw(&temp_zinit.ss_grid_yofs,f))
20214 {
20215 return qe_invalid;
20216 }
20217
20218
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_igetw(&temp_zinit.ss_grid_color,f))
20219 {
20220 return qe_invalid;
20221 }
20222
20223
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_igetw(&temp_zinit.ss_bbox_1_color,f))
20224 {
20225 return qe_invalid;
20226 }
20227
20228
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_igetw(&temp_zinit.ss_bbox_2_color,f))
20229 {
20230 return qe_invalid;
20231 }
20232
20233
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_igetw(&temp_zinit.ss_flags,f))
20234 {
20235 return qe_invalid;
20236 }
20237
20238
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 222 times.
222 temp_zinit.ss_grid_x=zc_max(temp_zinit.ss_grid_x,1);
20239
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 222 times.
222 temp_zinit.ss_grid_y=zc_max(temp_zinit.ss_grid_y,1);
20240 222 }
20241
20242
3/4
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 222 times.
✗ Branch 3 not taken.
286 if(s_version>4 && s_version<15)
20243 {
20244 if(!p_getc(&moving_fairy_hearts,f))
20245 {
20246 return qe_invalid;
20247 }
20248
20249 if(!p_getc(&moving_fairy_heart_percent,f))
20250 {
20251 return qe_invalid;
20252 }
20253 }
20254
20255
3/4
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 222 times.
✗ Branch 3 not taken.
286 if(s_version>5 && s_version < 10)
20256 {
20257 if(!p_getc(&temp,f))
20258 {
20259 return qe_invalid;
20260 }
20261
20262 addOldStyleFamily(&temp_zinit, itemsbuf, itype_quiver, temp);
20263 }
20264
20265
3/4
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 222 times.
✗ Branch 3 not taken.
286 if(s_version>6 && s_version<15)
20266 {
20267 if(!p_getc(&stationary_fairy_hearts,f))
20268 {
20269 return qe_invalid;
20270 }
20271
20272 if(!p_getc(&stationary_fairy_heart_percent,f))
20273 {
20274 return qe_invalid;
20275 }
20276
20277 if(!p_getc(&moving_fairy_magic,f))
20278 {
20279 return qe_invalid;
20280 }
20281
20282 if(!p_getc(&moving_fairy_magic_percent,f))
20283 {
20284 return qe_invalid;
20285 }
20286
20287 if(!p_getc(&stationary_fairy_magic,f))
20288 {
20289 return qe_invalid;
20290 }
20291
20292 if(!p_getc(&stationary_fairy_magic_percent,f))
20293 {
20294 return qe_invalid;
20295 }
20296
20297 if(!p_getc(&blue_potion_hearts,f))
20298 {
20299 return qe_invalid;
20300 }
20301
20302 if(!p_getc(&blue_potion_heart_percent,f))
20303 {
20304 return qe_invalid;
20305 }
20306
20307 if(!p_getc(&red_potion_hearts,f))
20308 {
20309 return qe_invalid;
20310 }
20311
20312 if(!p_getc(&red_potion_heart_percent,f))
20313 {
20314 return qe_invalid;
20315 }
20316
20317 if(!p_getc(&blue_potion_magic,f))
20318 {
20319 return qe_invalid;
20320 }
20321
20322 if(!p_getc(&blue_potion_magic_percent,f))
20323 {
20324 return qe_invalid;
20325 }
20326
20327 if(!p_getc(&red_potion_magic,f))
20328 {
20329 return qe_invalid;
20330 }
20331
20332 if(!p_getc(&red_potion_magic_percent,f))
20333 {
20334 return qe_invalid;
20335 }
20336 }
20337
20338
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 222 times.
286 if(s_version>6)
20339
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_getc(&padding,f))
20340 return qe_invalid;
20341
20342
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 222 times.
286 if(s_version>7)
20343 {
20344
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_getc(&padding,f))
20345 {
20346 return qe_invalid;
20347 }
20348 222 }
20349
20350
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 222 times.
286 if(s_version>8)
20351 {
20352
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_igetw(&temp_zinit.mcounter[crMONEY],f))
20353 {
20354 return qe_invalid;
20355 }
20356
20357
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_igetw(&temp_zinit.mcounter[crKEYS],f))
20358 {
20359 return qe_invalid;
20360 }
20361 222 }
20362
20363
2/2
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 64 times.
286 if(s_version>16)
20364 {
20365
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_getc(&tempbyte,f))
20366 {
20367 return qe_invalid;
20368 }
20369 222 temp_zinit.gravity = tempbyte*100;
20370
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_igetw(&temp_zinit.terminalv,f))
20371 {
20372 return qe_invalid;
20373 }
20374
20375
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_getc(&temp_zinit.msg_speed,f))
20376 {
20377 return qe_invalid;
20378 }
20379
20380
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_getc(&padding,f))
20381 {
20382 return qe_invalid;
20383 }
20384
20385
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_getc(&temp_zinit.jump_hero_layer_threshold,f))
20386 {
20387 return qe_invalid;
20388 }
20389 222 }
20390
2/2
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 12 times.
64 else if (replay_version_check(0, 13))
20391 12 temp_zinit.msg_speed = 0;
20392
20393
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 222 times.
286 if(s_version>17)
20394 {
20395
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_getc(&temp_zinit.msg_more_is_offset,f))
20396 {
20397 return qe_invalid;
20398 }
20399 222 }
20400
20401 //expaned init data for larger values in 2.55
20402
2/2
✓ Branch 0 taken 269 times.
✓ Branch 1 taken 17 times.
286 if ( s_version >= 19 ) //expand init data bombs, sbombs, and arrows to 0xFFFF
20403 {
20404
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.counter[crBOMBS],f))
20405 {
20406 return qe_invalid;
20407 }
20408
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.counter[crSBOMBS],f))
20409 {
20410 return qe_invalid;
20411 }
20412
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.mcounter[crBOMBS],f))
20413 {
20414 return qe_invalid;
20415 }
20416
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.mcounter[crSBOMBS],f))
20417 {
20418 return qe_invalid;
20419 }
20420
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.counter[crARROWS],f))
20421 {
20422 return qe_invalid;
20423 }
20424
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.mcounter[crARROWS],f))
20425 {
20426 return qe_invalid;
20427 }
20428
20429 17 }
20430
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 269 times.
286 if ( s_version >= 20 )
20431 {
20432
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.heroStep,f))
20433 {
20434 return qe_invalid;
20435 }
20436 17 }
20437 else
20438 {
20439 269 temp_zinit.heroStep = 150; //1.5 pixels per frame
20440 }
20441
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 269 times.
286 if ( s_version >= 21 )
20442 {
20443
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.subscrSpeed,f))
20444 {
20445 return qe_invalid;
20446 }
20447 17 }
20448 else
20449 {
20450 269 temp_zinit.subscrSpeed = 1; //3 pixels per frame
20451 }
20452 //old only
20453
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 281 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
286 if((Header->zelda_version == 0x192)&&(Header->build<174))
20454 {
20455 byte items2;
20456
20457
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&items2,f))
20458 {
20459 return qe_invalid;
20460 }
20461
20462 4 temp_zinit.set_item(iDivineFire, get_bit(&items2, idI_DFIRE)!=0);
20463 4 temp_zinit.set_item(iDivineEscape, get_bit(&items2, idI_FWIND)!=0);
20464 4 temp_zinit.set_item(iDivineProtection, get_bit(&items2, idI_NLOVE)!=0);
20465 4 }
20466
20467
2/2
✓ Branch 0 taken 281 times.
✓ Branch 1 taken 5 times.
286 if(Header->zelda_version < 0x193)
20468 {
20469
2/2
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 5 times.
485 for(int32_t q=0; q<96; q++)
20470 {
20471
1/2
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
480 if(!p_getc(&padding,f))
20472 {
20473 return qe_invalid;
20474 }
20475 480 }
20476
20477 //new only
20478
3/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 1 times.
5 if((Header->zelda_version == 0x192)&&(Header->build>173))
20479 {
20480
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_getc(&padding,f))
20481 {
20482 return qe_invalid;
20483 }
20484
20485
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_getc(&padding,f))
20486 {
20487 return qe_invalid;
20488 }
20489 1 }
20490 5 }
20491 286 }
20492
20493
3/6
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 82 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 222 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
304 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<15)))
20494 {
20495 //temp_zinit.shield=i_smallshield;
20496 82 int32_t sshieldid = getItemID(itemsbuf, itype_shield, i_smallshield);
20497
20498
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if(sshieldid != -1)
20499 82 temp_zinit.set_item(sshieldid, true);
20500 82 }
20501
20502
5/6
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 281 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
304 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<27)))
20503 {
20504 18 temp_zinit.mcounter[crLIFE]=3;
20505 18 temp_zinit.counter[crLIFE]=3;
20506 18 temp_zinit.cont_heart=3;
20507 18 temp_zinit.mcounter[crBOMBS]=8;
20508 18 }
20509
20510
5/6
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 281 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
304 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<50)))
20511 {
20512 18 sword_hearts[0]=0;
20513 18 sword_hearts[1]=5;
20514 18 sword_hearts[2]=12;
20515 18 sword_hearts[3]=21;
20516 18 }
20517
20518
5/6
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 281 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
304 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<51)))
20519 {
20520 18 temp_zinit.last_map=0;
20521 18 temp_zinit.last_screen=0;
20522 18 }
20523
20524
5/6
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 281 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
304 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<68)))
20525 {
20526 18 temp_zinit.mcounter[crMAGIC]=0;
20527 18 temp_zinit.counter[crMAGIC]=0;
20528 18 temp_zinit.magicdrainrate = 2;
20529 18 }
20530
20531
5/6
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 281 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
304 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<129)))
20532 {
20533
20534
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
90 for(int32_t x=0; x<4; x++)
20535 {
20536 72 beam_hearts[x]=100;
20537 72 }
20538
20539
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
90 for(int32_t i=0; i<idBP_MAX; i++)
20540 {
20541 72 set_bit(&beam_percent,i,!get_qr(qr_LENSHINTS+i));
20542 72 set_qr(qr_LENSHINTS+i,0);
20543 72 }
20544
20545
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
90 for(int32_t x=0; x<4; x++)
20546 {
20547 72 beam_power[x]=get_qr(qr_HIDECARRIEDITEMS)?50:100;
20548 72 }
20549
20550 18 set_qr(qr_HIDECARRIEDITEMS,0);
20551 18 hookshot_links=100;
20552 18 temp_zinit.msg_more_x=224;
20553 18 temp_zinit.msg_more_y=64;
20554 18 }
20555
20556 // Okay, let's put these legacy values into itemsbuf.
20557
2/2
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 82 times.
304 if(s_version < 15)
20558
2/2
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 82 times.
21074 for(int32_t i=0; i<MAXITEMS; i++)
20559 {
20560
11/11
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 82 times.
✓ Branch 5 taken 82 times.
✓ Branch 6 taken 82 times.
✓ Branch 7 taken 82 times.
✓ Branch 8 taken 20172 times.
✓ Branch 9 taken 82 times.
✓ Branch 10 taken 82 times.
20992 switch(i)
20561 {
20562 case iFairyStill:
20563 82 itemsbuf[i].misc1 = stationary_fairy_hearts;
20564 82 itemsbuf[i].misc2 = stationary_fairy_magic;
20565 82 itemsbuf[i].misc3 = 0;
20566
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if (stationary_fairy_heart_percent) itemsbuf[i].flags |= item_flag1;
20567
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if (stationary_fairy_magic_percent) itemsbuf[i].flags |= item_flag2;
20568 82 break;
20569
20570 case iFairyMoving:
20571 82 itemsbuf[i].misc1 = moving_fairy_hearts;
20572 82 itemsbuf[i].misc2 = moving_fairy_magic;
20573 82 itemsbuf[i].misc3 = 50;
20574
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if (moving_fairy_heart_percent) itemsbuf[i].flags |= item_flag1;
20575
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if (moving_fairy_magic_percent) itemsbuf[i].flags |= item_flag2;
20576 82 break;
20577
20578 case iRPotion:
20579 82 itemsbuf[i].misc1 = red_potion_hearts;
20580 82 itemsbuf[i].misc2 = red_potion_magic;
20581
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if (red_potion_heart_percent) itemsbuf[i].flags |= item_flag1;
20582
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if (red_potion_magic_percent) itemsbuf[i].flags |= item_flag2;
20583 82 break;
20584
20585 case iBPotion:
20586 82 itemsbuf[i].misc1 = blue_potion_hearts;
20587 82 itemsbuf[i].misc2 = blue_potion_magic;
20588
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if (blue_potion_heart_percent) itemsbuf[i].flags |= item_flag1;
20589
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if (blue_potion_magic_percent) itemsbuf[i].flags |= item_flag2;
20590 82 break;
20591
20592 case iSword:
20593 82 itemsbuf[i].pickup_hearts = sword_hearts[0];
20594 82 itemsbuf[i].misc1 = beam_hearts[0];
20595 82 itemsbuf[i].misc2 = beam_power[0];
20596 // It seems that item_flag1 was already added by reset_itembuf()...
20597 82 itemsbuf[i].flags &= (!get_bit(&beam_percent,0)) ? ~item_flag1 : ~item_none;
20598 82 break;
20599
20600 case iWSword:
20601 82 itemsbuf[i].pickup_hearts = sword_hearts[1];
20602 82 itemsbuf[i].misc1 = beam_hearts[1];
20603 82 itemsbuf[i].misc2 = beam_power[1];
20604 82 itemsbuf[i].flags &= (!get_bit(&beam_percent,1)) ? ~item_flag1 : ~item_none;
20605 82 break;
20606
20607 case iMSword:
20608 82 itemsbuf[i].pickup_hearts = sword_hearts[2];
20609 82 itemsbuf[i].misc1 = beam_hearts[2];
20610 82 itemsbuf[i].misc2 = beam_power[2];
20611 82 itemsbuf[i].flags &= (!get_bit(&beam_percent,2)) ? ~item_flag1 : ~item_none;
20612 82 break;
20613
20614 case iXSword:
20615 82 itemsbuf[i].pickup_hearts = sword_hearts[3];
20616 82 itemsbuf[i].misc1 = beam_hearts[3];
20617 82 itemsbuf[i].misc2 = beam_power[3];
20618 82 itemsbuf[i].flags &= (!get_bit(&beam_percent,3)) ? ~item_flag1 : ~item_none;
20619 82 break;
20620
20621 case iHookshot:
20622 82 itemsbuf[i].misc1 = hookshot_length;
20623 82 itemsbuf[i].misc2 = hookshot_links;
20624 82 break;
20625
20626 case iLongshot:
20627 82 itemsbuf[i].misc1 = longshot_length;
20628 82 itemsbuf[i].misc2 = longshot_links;
20629 82 break;
20630 }
20631 21074 }
20632
20633
6/6
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 281 times.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 1 times.
304 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<168)))
20634 {
20635 //was new subscreen rule
20636 22 subscr_mode=get_qr(qr_FREEFORM)?1:0;
20637 22 set_qr(qr_FREEFORM,0);
20638 22 }
20639
20640
5/6
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 281 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
304 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<185)))
20641 {
20642 23 temp_zinit.start_dmap=0;
20643 23 }
20644
20645
5/6
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 281 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
304 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<186)))
20646 {
20647 23 temp_zinit.heroAnimationStyle=get_qr(qr_BSZELDA)?1:0;
20648 23 }
20649
20650
3/4
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 222 times.
✓ Branch 2 taken 82 times.
✗ Branch 3 not taken.
304 if(s_version < 16 && get_bit(deprecated_rules, qr_COOLSCROLL+1))
20651 {
20652 //addOldStyleFamily(&temp_zinit, itemsbuf, itype_wallet, 4); //is this needed?
20653 temp_zinit.mcounter[crMONEY]=999;
20654 //temp_zinit.counter[crMONEY]=999; //This rule only gave you an invisible max wallet; it did not give you max rupies.
20655 }
20656
2/2
✓ Branch 0 taken 298 times.
✓ Branch 1 taken 6 times.
304 if(Header->zelda_version < 0x190) //1.84 bugfix. -Z
20657 {
20658 //temp_zinit.items[iBombBag] = true; //No, this is 30 max bombs!
20659 6 temp_zinit.mcounter[crBOMBS] = 8;
20660 6 }
20661 // al_trace("About to copy over new init data values for quest made in: %x\n", Header->zelda_version);
20662 //time to ensure that we port all new values properly:
20663
2/2
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 82 times.
304 if(Header->zelda_version < 0x250)
20664 {
20665
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 temp_zinit.mcounter[crSBOMBS] = bomb_ratio > 0 ? ( temp_zinit.mcounter[crBOMBS]/temp_zinit.bomb_ratio ) : (temp_zinit.mcounter[crBOMBS]/4);
20666 82 }
20667
20668
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 287 times.
304 if(s_version > 21)
20669 {
20670
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.hp_per_heart,f))
20671 {
20672 return qe_invalid;
20673 }
20674
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.magic_per_block,f))
20675 {
20676 return qe_invalid;
20677 }
20678
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.hero_damage_multiplier,f))
20679 {
20680 return qe_invalid;
20681 }
20682
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.ene_damage_multiplier,f))
20683 {
20684 return qe_invalid;
20685 }
20686 17 }
20687 else
20688 {
20689 287 temp_zinit.hp_per_heart = 16; //HP_PER_HEART, previously hardcoded
20690 287 temp_zinit.magic_per_block = 32; //MAGICPERBLOCK, previously hardcoded
20691 287 temp_zinit.hero_damage_multiplier = 2; //DAMAGE_MULTIPLIER, previously hardcoded
20692 287 temp_zinit.ene_damage_multiplier = 4; //(HP_PER_HEART/4), previously hardcoded
20693 }
20694
20695
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 17 times.
304 if(s_version > 22)
20696 {
20697
2/2
✓ Branch 0 taken 425 times.
✓ Branch 1 taken 17 times.
442 for(int32_t q = crCUSTOM1; q <= crCUSTOM25; ++q)
20698
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 425 times.
425 if(!p_igetw(&temp_zinit.counter[q],f))
20699 return qe_invalid;
20700
2/2
✓ Branch 0 taken 425 times.
✓ Branch 1 taken 17 times.
442 for(int32_t q = crCUSTOM1; q <= crCUSTOM25; ++q)
20701
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 425 times.
425 if(!p_igetw(&temp_zinit.mcounter[q],f))
20702 return qe_invalid;
20703 17 }
20704
20705
20706
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 287 times.
304 if(s_version > 23)
20707 {
20708
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.dither_type,f))
20709 {
20710 return qe_invalid;
20711 }
20712
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.dither_arg,f))
20713 {
20714 return qe_invalid;
20715 }
20716
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.dither_percent,f))
20717 {
20718 return qe_invalid;
20719 }
20720
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.def_lightrad,f))
20721 {
20722 return qe_invalid;
20723 }
20724
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.transdark_percent,f))
20725 {
20726 return qe_invalid;
20727 }
20728 17 }
20729 else
20730 {
20731 287 temp_zinit.dither_type = 0;
20732 287 temp_zinit.dither_arg = 0;
20733 287 temp_zinit.dither_percent = 20;
20734 287 temp_zinit.def_lightrad = 24;
20735 287 temp_zinit.transdark_percent = 0;
20736 }
20737
20738
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 287 times.
304 if(s_version > 24)
20739 {
20740
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.darkcol,f))
20741 {
20742 return qe_invalid;
20743 }
20744 17 }
20745 else
20746 {
20747 287 temp_zinit.darkcol = BLACK;
20748 }
20749
20750
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 17 times.
304 if(s_version > 25)
20751 {
20752
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetl(&temp_zinit.gravity,f))
20753 {
20754 return qe_invalid;
20755 }
20756
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetl(&temp_zinit.swimgravity,f))
20757 {
20758 return qe_invalid;
20759 }
20760 17 }
20761
20762
20763
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 287 times.
304 if(s_version > 26)
20764 {
20765
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.heroSideswimUpStep,f))
20766 {
20767 return qe_invalid;
20768 }
20769
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.heroSideswimSideStep,f))
20770 {
20771 return qe_invalid;
20772 }
20773
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.heroSideswimDownStep,f))
20774 {
20775 return qe_invalid;
20776 }
20777 17 }
20778 else
20779 {
20780 287 temp_zinit.heroSideswimUpStep = 150;
20781 287 temp_zinit.heroSideswimSideStep = 100;
20782 287 temp_zinit.heroSideswimDownStep = 75;
20783 }
20784
20785
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 287 times.
304 if(s_version > 27)
20786 {
20787
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetl(&temp_zinit.exitWaterJump,f))
20788 {
20789 return qe_invalid;
20790 }
20791 17 }
20792 else
20793 {
20794 287 temp_zinit.exitWaterJump = 0;
20795 }
20796
20797
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 287 times.
304 if(s_version > 29)
20798 {
20799
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetl(&temp_zinit.bunny_ltm,f))
20800 {
20801 return qe_invalid;
20802 }
20803 17 }
20804 else
20805 {
20806 287 temp_zinit.bunny_ltm = 0;
20807 }
20808
20809
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 287 times.
304 if(s_version > 30)
20810 {
20811
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.switchhookstyle,f))
20812 {
20813 return qe_invalid;
20814 }
20815 17 }
20816 else
20817 {
20818 287 temp_zinit.switchhookstyle = 1;
20819 }
20820
20821
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 17 times.
304 if(s_version > 31)
20822 {
20823
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.magicdrainrate,f))
20824 {
20825 return qe_invalid;
20826 }
20827 17 }
20828
20829 304 temp_zinit.clear_genscript();
20830
2/2
✓ Branch 0 taken 292 times.
✓ Branch 1 taken 12 times.
304 if(s_version > 32)
20831 {
20832 12 word numgenscript = 0;
20833
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetw(&numgenscript,f))
20834 return qe_invalid;
20835
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if (numgenscript > NUMSCRIPTSGENERIC)
20836 return qe_invalid;
20837
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 for(auto q = 1; q < numgenscript; ++q)
20838 {
20839 if(!p_getc(&tempbyte,f))
20840 return qe_invalid;
20841 if(!(tempbyte&2))
20842 continue;
20843 temp_zinit.gen_doscript.set(q, tempbyte&1);
20844 if(!p_igetw(&temp_zinit.gen_exitState[q],f))
20845 return qe_invalid;
20846 if(!p_igetw(&temp_zinit.gen_reloadState[q],f))
20847 return qe_invalid;
20848 for(auto p = 0; p < 8; ++p)
20849 if(!p_igetl(&temp_zinit.gen_initd[q][p],f))
20850 return qe_invalid;
20851 dword sz;
20852 if(!p_igetl(&sz,f))
20853 return qe_invalid;
20854 temp_zinit.gen_data[q].resize(sz);
20855 std::vector<int32_t> dummy;
20856 if(!p_getlvec(&dummy,f))
20857 return qe_invalid;
20858 temp_zinit.gen_data[q] = dummy;
20859 if(!p_igetl(&temp_zinit.gen_eventstate[q],f))
20860 return qe_invalid;
20861 }
20862 12 }
20863
2/2
✓ Branch 0 taken 298 times.
✓ Branch 1 taken 6 times.
304 if(s_version > 33)
20864 {
20865
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(!p_getc(&temp_zinit.hero_swim_mult,f))
20866 return qe_invalid;
20867
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(!p_getc(&temp_zinit.hero_swim_div,f))
20868 return qe_invalid;
20869 6 }
20870
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(s_version > 34)
20871 {
20872 uint32_t num_used_mapscr_data;
20873 if(!p_igetl(&num_used_mapscr_data,f))
20874 return qe_invalid;
20875 for(uint32_t q = 0; q < num_used_mapscr_data; ++q)
20876 {
20877 uint32_t sz;
20878 if(!p_igetl(&sz,f))
20879 return qe_invalid;
20880 temp_zinit.screen_data[q].resize(sz);
20881 if(sz)
20882 {
20883 std::vector<int32_t> dummy;
20884 if(!p_getlvec(&dummy,f))
20885 return qe_invalid;
20886 temp_zinit.screen_data[q] = dummy;
20887 }
20888 }
20889 }
20890
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if (s_version > 35)
20891 if(!p_igetzf(&temp_zinit.shove_offset,f))
20892 return qe_invalid;
20893
20894 304 temp_zinit.counter[crLIFE] *= temp_zinit.hp_per_heart;
20895 304 temp_zinit.mcounter[crLIFE] *= temp_zinit.hp_per_heart;
20896
2/2
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 110 times.
304 if(!temp_zinit.flags.get(INIT_FL_CONTPERCENT))
20897 110 temp_zinit.cont_heart *= temp_zinit.hp_per_heart;
20898
20899 304 return 0;
20900 304 }
20901 477 int32_t readinitdata(PACKFILE *f, zquestheader *Header)
20902 {
20903 477 zinitdata temp_zinit = {};
20904
20905
3/4
✓ Branch 0 taken 454 times.
✓ Branch 1 taken 23 times.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
477 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_initdata);
20906
20907 int32_t dummy;
20908 477 word s_version=0;
20909 byte padding;
20910
20911
2/2
✓ Branch 0 taken 454 times.
✓ Branch 1 taken 23 times.
477 if(Header->zelda_version > 0x192)
20912 {
20913
2/4
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 454 times.
✗ Branch 3 not taken.
454 if(!p_igetw(&s_version,f))
20914 return qe_invalid;
20915 454 FFCore.quest_format[vInitData] = s_version;
20916
20917
2/4
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 454 times.
✗ Branch 3 not taken.
454 if(!read_deprecated_section_cversion(f))
20918 return qe_invalid;
20919
20920 //section size
20921
2/4
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 454 times.
✗ Branch 3 not taken.
454 if(!p_igetl(&dummy,f))
20922 return qe_invalid;
20923 454 }
20924
20925
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 173 times.
477 if(s_version < 37)
20926 {
20927
2/4
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 304 times.
304 if(auto ret = readinitdata_old(f,Header,s_version,temp_zinit))
20928 return ret;
20929 304 }
20930 else
20931 {
20932 173 subscr_mode = ssdtMAX;
20933
2/2
✓ Branch 0 taken 5536 times.
✓ Branch 1 taken 173 times.
5709 for(int q = 0; q < MAXITEMS/8; ++q)
20934
2/4
✓ Branch 0 taken 5536 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5536 times.
5536 if(!p_getc(&temp_zinit.items[q], f))
20935 return qe_invalid;
20936
2/2
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 46 times.
173 if(s_version >= 42)
20937 {
20938
2/2
✓ Branch 0 taken 65024 times.
✓ Branch 1 taken 127 times.
65151 for(int q = 0; q < MAXLEVELS; ++q)
20939 {
20940
2/4
✓ Branch 0 taken 65024 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 65024 times.
65024 if(!p_getc(&temp_zinit.litems[q], f))
20941 return qe_invalid;
20942 65024 }
20943 127 }
20944 else
20945 {
20946 byte tmp_map[MAXLEVELS/8];
20947 byte tmp_compass[MAXLEVELS/8];
20948 byte tmp_boss_key[MAXLEVELS/8];
20949 byte tmp_mcguffin[MAXLEVELS/8];
20950
2/2
✓ Branch 0 taken 2944 times.
✓ Branch 1 taken 46 times.
2990 for(int q = 0; q < MAXLEVELS/8; ++q)
20951 {
20952
2/4
✓ Branch 0 taken 2944 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2944 times.
✗ Branch 3 not taken.
2944 if(!p_getc(&tmp_map[q], f))
20953 return qe_invalid;
20954
2/4
✓ Branch 0 taken 2944 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2944 times.
2944 if(!p_getc(&tmp_compass[q], f))
20955 return qe_invalid;
20956
2/4
✓ Branch 0 taken 2944 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2944 times.
2944 if(!p_getc(&tmp_boss_key[q], f))
20957 return qe_invalid;
20958
2/4
✓ Branch 0 taken 2944 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2944 times.
✗ Branch 3 not taken.
2944 if(!p_getc(&tmp_mcguffin[q], f))
20959 return qe_invalid;
20960 2944 }
20961
2/2
✓ Branch 0 taken 23552 times.
✓ Branch 1 taken 46 times.
23598 for(int q = 0; q < MAXLEVELS; ++q)
20962 {
20963
2/4
✓ Branch 0 taken 23552 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 23552 times.
23552 SETFLAG(temp_zinit.litems[q], liMAP, get_bit(tmp_map, q));
20964
3/4
✓ Branch 0 taken 23552 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
✓ Branch 3 taken 23532 times.
23552 SETFLAG(temp_zinit.litems[q], liCOMPASS, get_bit(tmp_compass, q));
20965
2/4
✓ Branch 0 taken 23552 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 23552 times.
23552 SETFLAG(temp_zinit.litems[q], liBOSSKEY, get_bit(tmp_boss_key, q));
20966
3/4
✓ Branch 0 taken 23552 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 144 times.
✓ Branch 3 taken 23408 times.
23552 SETFLAG(temp_zinit.litems[q], liTRIFORCE, get_bit(tmp_mcguffin, q));
20967 23552 }
20968 }
20969
2/4
✓ Branch 0 taken 173 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 173 times.
✗ Branch 3 not taken.
173 if(!p_getbvec(&temp_zinit.level_keys, f))
20970 return qe_invalid;
20971 byte num_counters;
20972
2/4
✓ Branch 0 taken 173 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 173 times.
✗ Branch 3 not taken.
173 if(!p_getc(&num_counters,f))
20973 return qe_invalid;
20974
2/2
✓ Branch 0 taken 18511 times.
✓ Branch 1 taken 173 times.
18684 for(int q = 0; q < num_counters; ++q)
20975
2/4
✓ Branch 0 taken 18511 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 18511 times.
18511 if(!p_igetw(&temp_zinit.counter[q],f))
20976 return qe_invalid;
20977
2/2
✓ Branch 0 taken 173 times.
✓ Branch 1 taken 18511 times.
18684 for(int q = 0; q < num_counters; ++q)
20978
2/4
✓ Branch 0 taken 18511 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 18511 times.
18511 if(!p_igetw(&temp_zinit.mcounter[q],f))
20979 return qe_invalid;
20980
2/4
✓ Branch 0 taken 173 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 173 times.
✗ Branch 3 not taken.
173 if(!p_getc(&temp_zinit.bomb_ratio,f))
20981 return qe_invalid;
20982
2/4
✓ Branch 0 taken 173 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 173 times.
✗ Branch 3 not taken.
173 if(!p_getc(&temp_zinit.hcp,f))
20983 return qe_invalid;
20984
2/4
✓ Branch 0 taken 173 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 173 times.
✗ Branch 3 not taken.
173 if(!p_getc(&temp_zinit.hcp_per_hc,f))
20985 return qe_invalid;
20986
2/4
✓ Branch 0 taken 173 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 173 times.
✗ Branch 3 not taken.
173 if(!p_igetw(&temp_zinit.cont_heart,f))
20987 return qe_invalid;
20988
2/4
✓ Branch 0 taken 173 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 173 times.
✗ Branch 3 not taken.
173 if(!p_getc(&temp_zinit.hp_per_heart,f))
20989 return qe_invalid;
20990
2/4
✓ Branch 0 taken 173 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 173 times.
✗ Branch 3 not taken.
173 if(!p_getc(&temp_zinit.magic_per_block,f))
20991 return qe_invalid;
20992
2/4
✓ Branch 0 taken 173 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 173 times.
✗ Branch 3 not taken.
173 if(!p_getc(&temp_zinit.hero_damage_multiplier,f))
20993 return qe_invalid;
20994
2/4
✓ Branch 0 taken 173 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 173 times.
✗ Branch 3 not taken.
173 if(!p_getc(&temp_zinit.ene_damage_multiplier,f))
20995 return qe_invalid;
20996
2/4
✓ Branch 0 taken 173 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 173 times.
✗ Branch 3 not taken.
173 if(!p_getc(&temp_zinit.dither_type,f))
20997 return qe_invalid;
20998
2/4
✓ Branch 0 taken 173 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 173 times.
✗ Branch 3 not taken.
173 if(!p_getc(&temp_zinit.dither_arg,f))
20999 return qe_invalid;
21000
2/4
✓ Branch 0 taken 173 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 173 times.
✗ Branch 3 not taken.
173 if(!p_getc(&temp_zinit.dither_percent,f))
21001 return qe_invalid;
21002
2/4
✓ Branch 0 taken 173 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 173 times.
✗ Branch 3 not taken.
173 if(!p_getc(&temp_zinit.def_lightrad,f))
21003 return qe_invalid;
21004
2/4
✓ Branch 0 taken 173 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 173 times.
✗ Branch 3 not taken.
173 if(!p_getc(&temp_zinit.transdark_percent,f))
21005 return qe_invalid;
21006
2/4
✓ Branch 0 taken 173 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 173 times.
✗ Branch 3 not taken.
173 if(!p_getc(&temp_zinit.darkcol,f))
21007 return qe_invalid;
21008
2/4
✓ Branch 0 taken 173 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 173 times.
✗ Branch 3 not taken.
173 if(!p_igetl(&temp_zinit.ss_grid_x,f))
21009 return qe_invalid;
21010
2/4
✓ Branch 0 taken 173 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 173 times.
✗ Branch 3 not taken.
173 if(!p_igetl(&temp_zinit.ss_grid_y,f))
21011 return qe_invalid;
21012
2/4
✓ Branch 0 taken 173 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 173 times.
✗ Branch 3 not taken.
173 if(!p_igetl(&temp_zinit.ss_grid_xofs,f))
21013 return qe_invalid;
21014
2/4
✓ Branch 0 taken 173 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 173 times.
173 if(!p_igetl(&temp_zinit.ss_grid_yofs,f))
21015 return qe_invalid;
21016
2/4
✓ Branch 0 taken 173 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 173 times.
✗ Branch 3 not taken.
173 if(!p_igetl(&temp_zinit.ss_grid_color,f))
21017 return qe_invalid;
21018
2/4
✓ Branch 0 taken 173 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 173 times.
✗ Branch 3 not taken.
173 if(!p_igetl(&temp_zinit.ss_bbox_1_color,f))
21019 return qe_invalid;
21020
2/4
✓ Branch 0 taken 173 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 173 times.
✗ Branch 3 not taken.
173 if(!p_igetl(&temp_zinit.ss_bbox_2_color,f))
21021 return qe_invalid;
21022
2/4
✓ Branch 0 taken 173 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 173 times.
✗ Branch 3 not taken.
173 if(!p_igetl(&temp_zinit.ss_flags,f))
21023 return qe_invalid;
21024
2/4
✓ Branch 0 taken 173 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 173 times.
✗ Branch 3 not taken.
173 if(!p_getbitstr(&temp_zinit.flags,f))
21025 return qe_invalid;
21026
2/4
✓ Branch 0 taken 173 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 173 times.
✗ Branch 3 not taken.
173 if(!p_getc(&temp_zinit.last_map,f))
21027 return qe_invalid;
21028
2/4
✓ Branch 0 taken 173 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 173 times.
✗ Branch 3 not taken.
173 if(!p_getc(&temp_zinit.last_screen,f))
21029 return qe_invalid;
21030
2/4
✓ Branch 0 taken 173 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 173 times.
✗ Branch 3 not taken.
173 if(!p_getc(&temp_zinit.msg_more_x,f))
21031 return qe_invalid;
21032
2/4
✓ Branch 0 taken 173 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 173 times.
✗ Branch 3 not taken.
173 if(!p_getc(&temp_zinit.msg_more_y,f))
21033 return qe_invalid;
21034
2/4
✓ Branch 0 taken 173 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 173 times.
✗ Branch 3 not taken.
173 if(!p_getc(&temp_zinit.msg_more_is_offset,f))
21035 return qe_invalid;
21036
2/4
✓ Branch 0 taken 173 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 173 times.
✗ Branch 3 not taken.
173 if(!p_getc(&temp_zinit.msg_speed,f))
21037 return qe_invalid;
21038
2/4
✓ Branch 0 taken 173 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 173 times.
✗ Branch 3 not taken.
173 if(!p_igetl(&temp_zinit.gravity,f))
21039 return qe_invalid;
21040
2/4
✓ Branch 0 taken 173 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 173 times.
✗ Branch 3 not taken.
173 if(!p_igetl(&temp_zinit.swimgravity,f))
21041 return qe_invalid;
21042
2/4
✓ Branch 0 taken 173 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 173 times.
✗ Branch 3 not taken.
173 if(!p_igetw(&temp_zinit.terminalv,f))
21043 return qe_invalid;
21044
2/4
✓ Branch 0 taken 173 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 173 times.
✗ Branch 3 not taken.
173 if(!p_getc(&temp_zinit.hero_swim_speed,f))
21045 return qe_invalid;
21046
2/4
✓ Branch 0 taken 173 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 173 times.
✗ Branch 3 not taken.
173 if(!p_getc(&temp_zinit.hero_swim_mult,f))
21047 return qe_invalid;
21048
2/4
✓ Branch 0 taken 173 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 173 times.
✗ Branch 3 not taken.
173 if(!p_getc(&temp_zinit.hero_swim_div,f))
21049 return qe_invalid;
21050
2/4
✓ Branch 0 taken 173 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 173 times.
✗ Branch 3 not taken.
173 if(!p_igetw(&temp_zinit.heroSideswimUpStep,f))
21051 return qe_invalid;
21052
2/4
✓ Branch 0 taken 173 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 173 times.
✗ Branch 3 not taken.
173 if(!p_igetw(&temp_zinit.heroSideswimSideStep,f))
21053 return qe_invalid;
21054
2/4
✓ Branch 0 taken 173 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 173 times.
✗ Branch 3 not taken.
173 if(!p_igetw(&temp_zinit.heroSideswimDownStep,f))
21055 return qe_invalid;
21056
2/4
✓ Branch 0 taken 173 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 173 times.
✗ Branch 3 not taken.
173 if(!p_igetl(&temp_zinit.exitWaterJump,f))
21057 return qe_invalid;
21058
2/4
✓ Branch 0 taken 173 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 173 times.
✗ Branch 3 not taken.
173 if(!p_igetw(&temp_zinit.heroStep,f))
21059 return qe_invalid;
21060
2/4
✓ Branch 0 taken 173 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 173 times.
✗ Branch 3 not taken.
173 if(!p_getc(&temp_zinit.heroAnimationStyle,f))
21061 return qe_invalid;
21062
2/4
✓ Branch 0 taken 173 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 173 times.
✗ Branch 3 not taken.
173 if(!p_getc(&temp_zinit.jump_hero_layer_threshold,f))
21063 return qe_invalid;
21064
2/4
✓ Branch 0 taken 173 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 173 times.
✗ Branch 3 not taken.
173 if(!p_igetl(&temp_zinit.bunny_ltm,f))
21065 return qe_invalid;
21066
2/4
✓ Branch 0 taken 173 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 173 times.
✗ Branch 3 not taken.
173 if(!p_igetw(&temp_zinit.start_dmap,f))
21067 return qe_invalid;
21068
2/4
✓ Branch 0 taken 173 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 173 times.
✗ Branch 3 not taken.
173 if(!p_igetw(&temp_zinit.subscrSpeed,f))
21069 return qe_invalid;
21070
2/4
✓ Branch 0 taken 173 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 173 times.
✗ Branch 3 not taken.
173 if(!p_getc(&temp_zinit.switchhookstyle,f))
21071 return qe_invalid;
21072
2/4
✓ Branch 0 taken 173 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 173 times.
✗ Branch 3 not taken.
173 if(!p_getc(&temp_zinit.magicdrainrate,f))
21073 return qe_invalid;
21074
2/4
✓ Branch 0 taken 173 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 173 times.
✗ Branch 3 not taken.
173 if(!p_igetzf(&temp_zinit.shove_offset,f))
21075 return qe_invalid;
21076
2/4
✓ Branch 0 taken 173 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 173 times.
✗ Branch 3 not taken.
173 if(!p_getbitstr(&temp_zinit.gen_doscript, f))
21077 return qe_invalid;
21078
2/4
✓ Branch 0 taken 173 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 173 times.
✗ Branch 3 not taken.
173 if(!p_getbmap(&temp_zinit.gen_exitState, f))
21079 return qe_invalid;
21080
2/4
✓ Branch 0 taken 173 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 173 times.
✗ Branch 3 not taken.
173 if(!p_getbmap(&temp_zinit.gen_reloadState, f))
21081 return qe_invalid;
21082
2/4
✓ Branch 0 taken 173 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 173 times.
173 if(!p_getbmap(&temp_zinit.gen_initd, f))
21083 return qe_invalid;
21084
2/4
✓ Branch 0 taken 173 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 173 times.
✗ Branch 3 not taken.
173 if(!p_getbmap(&temp_zinit.gen_eventstate, f))
21085 return qe_invalid;
21086
2/4
✓ Branch 0 taken 173 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 173 times.
✗ Branch 3 not taken.
173 if(!p_getbmap(&temp_zinit.gen_data, f))
21087 return qe_invalid;
21088
2/4
✓ Branch 0 taken 173 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 173 times.
✗ Branch 3 not taken.
173 if(!p_getbmap(&temp_zinit.screen_data, f))
21089 return qe_invalid;
21090
1/2
✓ Branch 0 taken 173 times.
✗ Branch 1 not taken.
173 if (s_version >= 38)
21091 {
21092
2/4
✓ Branch 0 taken 173 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 173 times.
✗ Branch 3 not taken.
173 if (!p_getc(&temp_zinit.spriteflickerspeed, f))
21093 return qe_invalid;
21094
2/4
✓ Branch 0 taken 173 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 173 times.
✗ Branch 3 not taken.
173 if (!p_getc(&temp_zinit.spriteflickercolor, f))
21095 return qe_invalid;
21096
2/4
✓ Branch 0 taken 173 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 173 times.
✗ Branch 3 not taken.
173 if (!p_getc(&temp_zinit.spriteflickertransp, f))
21097 return qe_invalid;
21098 173 }
21099
2/2
✓ Branch 0 taken 145 times.
✓ Branch 1 taken 28 times.
173 if(s_version >= 39)
21100
2/4
✓ Branch 0 taken 145 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 145 times.
✗ Branch 3 not taken.
145 if(!p_igetzf(&temp_zinit.air_drag, f))
21101 return qe_invalid;
21102
21103 // TODO: this first branch can likely be removed, as it only fixes an issues
21104 // that existed for a handful of temporary z3 builds (and active users of that
21105 // fork would have been updating often, beyond s_version 40).
21106
3/4
✓ Branch 0 taken 145 times.
✓ Branch 1 taken 28 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 145 times.
173 if (Header->is_z3 && s_version == 40)
21107 {
21108 if(!p_getc(&temp_zinit.region_mapping, f))
21109 return qe_invalid;
21110 }
21111 else
21112 {
21113
2/2
✓ Branch 0 taken 145 times.
✓ Branch 1 taken 28 times.
173 if(s_version >= 40)
21114 {
21115
2/4
✓ Branch 0 taken 145 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 145 times.
✗ Branch 3 not taken.
145 if(!p_igetw(&temp_zinit.light_wave_rate, f))
21116 return qe_invalid;
21117
2/4
✓ Branch 0 taken 145 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 145 times.
✗ Branch 3 not taken.
145 if(!p_igetw(&temp_zinit.light_wave_size, f))
21118 return qe_invalid;
21119 145 }
21120
21121
2/2
✓ Branch 0 taken 145 times.
✓ Branch 1 taken 28 times.
173 if(s_version >= 41)
21122 {
21123
2/4
✓ Branch 0 taken 145 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 145 times.
✗ Branch 3 not taken.
145 if(!p_getc(&temp_zinit.region_mapping, f))
21124 return qe_invalid;
21125 145 }
21126 }
21127 }
21128
2/2
✓ Branch 0 taken 358 times.
✓ Branch 1 taken 119 times.
477 if(s_version >= 43)
21129
2/2
✓ Branch 0 taken 30464 times.
✓ Branch 1 taken 119 times.
30583 for(uint q = 0; q < NUM_BOTTLE_SLOTS; ++q)
21130
2/4
✓ Branch 0 taken 30464 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 30464 times.
30464 if (!p_getc(&temp_zinit.bottle_slot[q], f))
21131 119 return qe_invalid;
21132
1/2
✓ Branch 0 taken 477 times.
✗ Branch 1 not taken.
477 if (should_skip)
21133 return 0;
21134
21135
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 477 times.
477 if(loading_tileset_flags & TILESET_CLEARMAPS)
21136 {
21137 temp_zinit.last_map = 0;
21138 temp_zinit.last_screen = 0;
21139 temp_zinit.screen_data.clear();
21140 }
21141
1/2
✓ Branch 0 taken 477 times.
✗ Branch 1 not taken.
477 temp_zinit.normalize();
21142
1/2
✓ Branch 0 taken 477 times.
✗ Branch 1 not taken.
477 zinit = temp_zinit;
21143
21144
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 477 times.
477 if(zinit.heroAnimationStyle==las_zelda3slow)
21145 {
21146 hero_animation_speed=2;
21147 }
21148 else
21149 {
21150 477 hero_animation_speed=1;
21151 }
21152
21153 477 return 0;
21154 477 }
21155
21156 /*
21157 void setupitemdropsets()
21158 {
21159 for(int32_t i=0; i<isMAX; i++)
21160 {
21161 memcpy(&item_drop_sets[i], &default_item_drop_sets[i], sizeof(item_drop_object));
21162 }
21163 }
21164 */
21165
21166 418 int32_t readitemdropsets(PACKFILE *f, int32_t version)
21167 {
21168
2/2
✓ Branch 0 taken 395 times.
✓ Branch 1 taken 23 times.
418 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_itemdropsets);
21169
21170 dword dummy_dword;
21171 418 word item_drop_sets_to_read=0;
21172 item_drop_object tempitemdrop;
21173 418 word s_version=0;
21174
21175
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 418 times.
418 if (!should_skip)
21176
2/2
✓ Branch 0 taken 107008 times.
✓ Branch 1 taken 418 times.
107426 for(int32_t i=0; i<MAXITEMDROPSETS; i++)
21177 {
21178 107008 memset(&item_drop_sets[i], 0, sizeof(item_drop_object));
21179 107426 }
21180
21181
2/2
✓ Branch 0 taken 395 times.
✓ Branch 1 taken 23 times.
418 if(version > 0x192)
21182 {
21183 395 item_drop_sets_to_read=0;
21184
21185 //section version info
21186
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 if(!p_igetw(&s_version,f))
21187 {
21188 return qe_invalid;
21189 }
21190
21191 395 FFCore.quest_format[vItemDropsets] = s_version;
21192
21193
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 if(!read_deprecated_section_cversion(f))
21194 {
21195 return qe_invalid;
21196 }
21197
21198 //section size
21199
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 if(!p_igetl(&dummy_dword,f))
21200 {
21201 return qe_invalid;
21202 }
21203
21204 //finally... section data
21205
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 if(!p_igetw(&item_drop_sets_to_read,f))
21206 {
21207 return qe_invalid;
21208 }
21209
21210
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 395 times.
395 if (item_drop_sets_to_read > MAXITEMDROPSETS)
21211 {
21212 return qe_invalid;
21213 }
21214 395 }
21215 else
21216 {
21217 23 init_item_drop_sets();
21218 }
21219
21220
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 395 times.
418 if(s_version>=1)
21221 {
21222
2/2
✓ Branch 0 taken 5977 times.
✓ Branch 1 taken 395 times.
6372 for(int32_t i=0; i<item_drop_sets_to_read; i++)
21223 {
21224
1/2
✓ Branch 0 taken 5977 times.
✗ Branch 1 not taken.
5977 if(!p_getstr(tempitemdrop.name,sizeof(tempitemdrop.name)-1,f))
21225 {
21226 return qe_invalid;
21227 }
21228
21229
2/2
✓ Branch 0 taken 59770 times.
✓ Branch 1 taken 5977 times.
65747 for(int32_t j=0; j<10; ++j)
21230 {
21231
1/2
✓ Branch 0 taken 59770 times.
✗ Branch 1 not taken.
59770 if(!p_igetw(&tempitemdrop.item[j],f))
21232 {
21233 return qe_invalid;
21234 }
21235 59770 }
21236
21237
2/2
✓ Branch 0 taken 65747 times.
✓ Branch 1 taken 5977 times.
71724 for(int32_t j=0; j<11; ++j)
21238 {
21239
1/2
✓ Branch 0 taken 65747 times.
✗ Branch 1 not taken.
65747 if(!p_igetw(&tempitemdrop.chance[j],f))
21240 {
21241 return qe_invalid;
21242 }
21243 65747 }
21244
21245 // Dec 2008: Addition of the 'Tall Grass' set, #12,
21246 // overrides the quest's set #12.
21247
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5977 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5977 if(s_version<2 && i==12)
21248 continue;
21249
21250 // Deprecated: qr_NOCLOCKS and qr_ALLOW10RUPEEDROPS
21251
1/4
✓ Branch 0 taken 5977 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5977 if(s_version<2) for(int32_t j=0; j<10; ++j)
21252 {
21253 int32_t it = tempitemdrop.item[j];
21254
21255 if((itemsbuf[it].family == itype_rupee
21256 && ((itemsbuf[it].amount)&0xFFF) == 10)
21257 && !get_bit(deprecated_rules, qr_ALLOW10RUPEEDROPS_DEP))
21258 {
21259 tempitemdrop.chance[j+1]=0;
21260 }
21261 else if(itemsbuf[it].family == itype_clock && get_bit(deprecated_rules, qr_NOCLOCKS_DEP))
21262 {
21263 tempitemdrop.chance[j+1]=0;
21264 }
21265
21266 // From Sept 2007 to Dec 2008, non-gameplay items were prohibited.
21267 if(itemsbuf[it].family == itype_misc)
21268 {
21269 // If a non-gameplay item was selected, then item drop was aborted.
21270 // Reflect this by increasing the 'Nothing' chance accordingly.
21271 tempitemdrop.chance[0]+=tempitemdrop.chance[j+1];
21272 tempitemdrop.chance[j+1]=0;
21273 }
21274 }
21275
21276
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5977 times.
5977 if (!should_skip)
21277 5977 memcpy(&item_drop_sets[i], &tempitemdrop, sizeof(item_drop_object));
21278 5977 }
21279 395 }
21280
21281 418 return 0;
21282 418 }
21283
21284 395 int32_t readfavorites(PACKFILE *f, int32_t)
21285 {
21286
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_favorites);
21287
21288 int32_t temp_num;
21289 dword dummy_dword;
21290 word num_favorite_combos;
21291 word num_favorite_combo_aliases;
21292 395 word s_version=0;
21293
21294 //section version info
21295
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 if(!p_igetw(&s_version,f))
21296 {
21297 return qe_invalid;
21298 }
21299
21300
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 395 times.
395 if (!should_skip)
21301 395 FFCore.quest_format[vFavourites] = s_version;
21302
21303
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 if(!read_deprecated_section_cversion(f))
21304 {
21305 return qe_invalid;
21306 }
21307
21308 //section size
21309
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 if(!p_igetl(&dummy_dword,f))
21310 {
21311 return qe_invalid;
21312 }
21313
21314 395 word per_row = FAVORITECOMBO_PER_ROW;
21315 395 word per_page = FAVORITECOMBO_PER_PAGE;
21316
2/2
✓ Branch 0 taken 216 times.
✓ Branch 1 taken 179 times.
395 if(s_version >= 3)
21317
1/2
✓ Branch 0 taken 179 times.
✗ Branch 1 not taken.
179 if(!p_igetw(&per_row,f))
21318 return qe_invalid;
21319
2/2
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 173 times.
395 if(s_version >= 4)
21320
1/2
✓ Branch 0 taken 173 times.
✗ Branch 1 not taken.
173 if(!p_igetw(&per_page,f))
21321 return qe_invalid;
21322 //finally... section data
21323
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 if(!p_igetw(&num_favorite_combos,f))
21324 {
21325 return qe_invalid;
21326 }
21327
21328 //Hack; port old favorite combos
21329
3/4
✓ Branch 0 taken 216 times.
✓ Branch 1 taken 179 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 216 times.
395 if(s_version < 3 && num_favorite_combos == 100)
21330 216 per_row = 13;
21331
21332
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 395 times.
395 if (!should_skip)
21333
2/2
✓ Branch 0 taken 497700 times.
✓ Branch 1 taken 395 times.
498095 for(int q = 0; q < MAXFAVORITECOMBOS; ++q)
21334 498095 favorite_combos[q] = -1;
21335 395 byte favtype = 0;
21336
2/2
✓ Branch 0 taken 28203 times.
✓ Branch 1 taken 395 times.
28598 for(int32_t i=0; i<num_favorite_combos; i++)
21337 {
21338
2/2
✓ Branch 0 taken 6597 times.
✓ Branch 1 taken 21606 times.
28203 if (s_version >= 4)
21339 {
21340
1/2
✓ Branch 0 taken 6597 times.
✗ Branch 1 not taken.
6597 if (!p_getc(&favtype, f))
21341 {
21342 return qe_invalid;
21343 }
21344 6597 }
21345 else
21346 21606 favtype = 0;
21347
1/2
✓ Branch 0 taken 28203 times.
✗ Branch 1 not taken.
28203 if(!p_igetl(&temp_num,f))
21348 {
21349 return qe_invalid;
21350 }
21351
21352
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28203 times.
28203 if (should_skip)
21353 continue;
21354
21355
2/2
✓ Branch 0 taken 6597 times.
✓ Branch 1 taken 21606 times.
28203 if(per_row == FAVORITECOMBO_PER_ROW)
21356 {
21357 6597 favorite_combos[i] = temp_num;
21358 6597 favorite_combo_modes[i] = favtype;
21359 6597 }
21360 else
21361 {
21362 21606 int new_i = (i%per_row) + (i/per_row)*FAVORITECOMBO_PER_ROW;
21363 21606 favorite_combos[new_i]=temp_num;
21364 21606 favorite_combo_modes[new_i] = favtype;
21365 }
21366 28203 }
21367
21368 // Discard the separate favorite aliases list from previous versions
21369
2/2
✓ Branch 0 taken 173 times.
✓ Branch 1 taken 222 times.
395 if(s_version<4)
21370 {
21371
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if (!p_igetw(&num_favorite_combo_aliases, f))
21372 {
21373 return qe_invalid;
21374 }
21375
21376
2/2
✓ Branch 0 taken 21600 times.
✓ Branch 1 taken 222 times.
21822 for (int32_t i = 0; i < num_favorite_combo_aliases; i++)
21377 {
21378
1/2
✓ Branch 0 taken 21600 times.
✗ Branch 1 not taken.
21600 if (!p_igetl(&temp_num, f))
21379 {
21380 return qe_invalid;
21381 }
21382 21600 }
21383 222 }
21384
21385 395 word max_combo_cols = 0;
21386 395 word max_mappages = 0;
21387
2/2
✓ Branch 0 taken 216 times.
✓ Branch 1 taken 179 times.
395 if(s_version >= 2)
21388 {
21389
1/2
✓ Branch 0 taken 179 times.
✗ Branch 1 not taken.
179 if(!p_igetw(&max_combo_cols,f))
21390 return qe_invalid;
21391 179 int32_t tmp = 0, tmp2 = 0, tmp3 = 0;
21392
2/2
✓ Branch 0 taken 716 times.
✓ Branch 1 taken 179 times.
895 for(int q = 0; q < max_combo_cols; ++q)
21393 {
21394
1/2
✓ Branch 0 taken 716 times.
✗ Branch 1 not taken.
716 if(!p_igetl(&tmp,f))
21395 return qe_invalid;
21396
1/2
✓ Branch 0 taken 716 times.
✗ Branch 1 not taken.
716 if(!p_igetl(&tmp2,f))
21397 return qe_invalid;
21398
1/2
✓ Branch 0 taken 716 times.
✗ Branch 1 not taken.
716 if(!p_igetl(&tmp3,f))
21399 return qe_invalid;
21400
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 716 times.
716 if(q < MAX_COMBO_COLS)
21401 {
21402 716 First[q] = tmp;
21403 716 combo_alistpos[q] = tmp2;
21404 716 combo_pool_listpos[q] = tmp3;
21405 716 }
21406 716 }
21407
21408
1/2
✓ Branch 0 taken 179 times.
✗ Branch 1 not taken.
179 if(!p_igetw(&max_mappages,f))
21409 return qe_invalid;
21410
2/2
✓ Branch 0 taken 1611 times.
✓ Branch 1 taken 179 times.
1790 for(int q = 0; q < max_mappages; ++q)
21411 {
21412
1/2
✓ Branch 0 taken 1611 times.
✗ Branch 1 not taken.
1611 if(!p_igetl(&tmp,f))
21413 return qe_invalid;
21414
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1611 times.
1611 if(!p_igetl(&tmp2,f))
21415 return qe_invalid;
21416
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1611 times.
1611 if(q < MAX_MAPPAGE_BTNS)
21417 {
21418 1611 map_page[q].map = tmp;
21419 1611 map_page[q].screen = tmp2;
21420 1611 }
21421 1611 }
21422 179 }
21423
21424
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 395 times.
395 if (should_skip)
21425 return 0;
21426
21427
2/2
✓ Branch 0 taken 864 times.
✓ Branch 1 taken 395 times.
1259 for(int q = max_combo_cols; q < MAX_COMBO_COLS; ++q)
21428 {
21429 864 First[q] = 0;
21430 864 combo_alistpos[q] = 0;
21431 864 combo_pool_listpos[q] = 0;
21432 864 }
21433
2/2
✓ Branch 0 taken 1944 times.
✓ Branch 1 taken 395 times.
2339 for(int q = max_mappages; q < MAX_MAPPAGE_BTNS; ++q)
21434 {
21435 1944 map_page[q].map = 0;
21436 1944 map_page[q].screen = 0;
21437 1944 }
21438
21439 395 return 0;
21440 395 }
21441
21442 /*
21443 switch (ret) {
21444 case 0:
21445 break;
21446
21447 case qe_invalid:
21448 goto invalid;
21449 break;
21450 default:
21451 pack_fclose(f);
21452 if(!oldquest)
21453 delete_file(tmpfilename);
21454 return ret;
21455 break;
21456 }
21457 */
21458
21459 const char *skip_text[skip_max]=
21460 {
21461 "skip_header", "skip_rules", "skip_strings", "skip_misc",
21462 "skip_tiles", "skip_combos", "skip_comboaliases", "skip_csets",
21463 "skip_maps", "skip_dmaps", "skip_doors", "skip_items",
21464 "skip_weapons", "skip_colors", "skip_icons", "skip_initdata",
21465 "skip_guys", "skip_herosprites", "skip_subscreens", "skip_ffscript",
21466 "skip_sfx", "skip_midis", "skip_cheats", "skip_itemdropsets",
21467 "skip_favorites"
21468 };
21469
21470
21471 void port250QuestRules(){
21472
21473 portCandleRules(); //Candle
21474 portBombRules();
21475
21476 }
21477
21478 void portCandleRules()
21479 {
21480 bool hurtshero = get_qr(qr_FIREPROOFHERO);
21481 //itemdata itemsbuf;
21482 for ( int32_t q = 0; q < MAXITEMS; q++ )
21483 {
21484 if ( itemsbuf[q].family == itype_candle )
21485 {
21486 if ( hurtshero ) itemsbuf[q].flags |= item_flag2;
21487 else itemsbuf[q].flags &= ~ item_flag2;
21488 }
21489 }
21490 }
21491
21492 void portBombRules()
21493 {
21494 bool hurtshero = get_qr(qr_OUCHBOMBS);
21495 //itemdata itemsbuf;
21496 for ( int32_t q = 0; q < MAXITEMS; q++ )
21497 {
21498 if ( itemsbuf[q].family == itype_bomb )
21499 {
21500 if ( hurtshero ) itemsbuf[q].flags |= item_flag2;
21501 else itemsbuf[q].flags &= ~ item_flag2;
21502 }
21503 }
21504 }
21505
21506 18453 static int section_id_to_enum(int id)
21507 {
21508
24/27
✗ Branch 0 not taken.
✓ Branch 1 taken 798 times.
✓ Branch 2 taken 798 times.
✓ Branch 3 taken 798 times.
✓ Branch 4 taken 798 times.
✓ Branch 5 taken 798 times.
✓ Branch 6 taken 715 times.
✓ Branch 7 taken 798 times.
✓ Branch 8 taken 798 times.
✓ Branch 9 taken 798 times.
✓ Branch 10 taken 798 times.
✓ Branch 11 taken 798 times.
✓ Branch 12 taken 798 times.
✓ Branch 13 taken 715 times.
✓ Branch 14 taken 715 times.
✓ Branch 15 taken 798 times.
✓ Branch 16 taken 798 times.
✓ Branch 17 taken 739 times.
✓ Branch 18 taken 715 times.
✓ Branch 19 taken 715 times.
✓ Branch 20 taken 715 times.
✓ Branch 21 taken 798 times.
✓ Branch 22 taken 798 times.
✓ Branch 23 taken 739 times.
✓ Branch 24 taken 715 times.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
18453 switch (id)
21509 {
21510 case ID_HEADER: return skip_header;
21511 798 case ID_RULES: return skip_rules;
21512 798 case ID_STRINGS: return skip_strings;
21513 798 case ID_MISC: return skip_misc;
21514 798 case ID_TILES: return skip_tiles;
21515 798 case ID_COMBOS: return skip_combos;
21516 715 case ID_COMBOALIASES: return skip_comboaliases;
21517 798 case ID_CSETS: return skip_csets;
21518 798 case ID_MAPS: return skip_maps;
21519 798 case ID_DMAPS: return skip_dmaps;
21520 798 case ID_DOORS: return skip_doors;
21521 798 case ID_ITEMS: return skip_items;
21522 798 case ID_WEAPONS: return skip_weapons;
21523 715 case ID_COLORS: return skip_colors;
21524 715 case ID_ICONS: return skip_icons;
21525 798 case ID_INITDATA: return skip_initdata;
21526 798 case ID_GUYS: return skip_guys;
21527 739 case ID_HEROSPRITES: return skip_herosprites;
21528 715 case ID_SUBSCREEN: return skip_subscreens;
21529 715 case ID_FFSCRIPT: return skip_ffscript;
21530 715 case ID_SFX: return skip_sfx;
21531 798 case ID_MIDIS: return skip_midis;
21532 798 case ID_CHEATS: return skip_cheats;
21533 739 case ID_ITEMDROPSETS: return skip_itemdropsets;
21534 715 case ID_FAVORITES: return skip_favorites;
21535 case ID_ZINFO: return skip_zinfo;
21536 }
21537
21538 return -1;
21539 18453 }
21540
21541 18045 static int maybe_skip_section(PACKFILE* f, dword& section_id, const byte* skip_flags)
21542 {
21543 18045 int section_enum = section_id_to_enum(section_id);
21544
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18045 times.
18045 bool skip = section_enum >= 0 && get_bit(skip_flags, section_enum);
21545
2/2
✓ Branch 0 taken 6720 times.
✓ Branch 1 taken 11325 times.
18045 if (skip)
21546 {
21547 word s_version;
21548
1/2
✓ Branch 0 taken 6720 times.
✗ Branch 1 not taken.
6720 if (!p_igetw(&s_version,f))
21549 {
21550 return qe_invalid;
21551 }
21552
21553
1/2
✓ Branch 0 taken 6720 times.
✗ Branch 1 not taken.
6720 if (!read_deprecated_section_cversion(f))
21554 {
21555 return qe_invalid;
21556 }
21557
21558
3/4
✓ Branch 0 taken 320 times.
✓ Branch 1 taken 6400 times.
✓ Branch 2 taken 320 times.
✗ Branch 3 not taken.
6720 if (section_id == ID_RULES && s_version > 16)
21559 {
21560 dword dummy;
21561 if (!p_igetl(&dummy,f))
21562 {
21563 return qe_invalid;
21564 }
21565 }
21566
21567
3/4
✓ Branch 0 taken 320 times.
✓ Branch 1 taken 6400 times.
✓ Branch 2 taken 320 times.
✗ Branch 3 not taken.
6720 if (section_id == ID_FFSCRIPT && s_version >= 18)
21568 {
21569 word dummy;
21570 if (!p_igetw(&dummy,f))
21571 {
21572 return qe_invalid;
21573 }
21574 }
21575
21576 dword section_length;
21577
1/2
✓ Branch 0 taken 6720 times.
✗ Branch 1 not taken.
6720 if (!p_igetl(&section_length,f))
21578 {
21579 return qe_invalid;
21580 }
21581
21582
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6720 times.
6720 if (pack_fseek(f, section_length))
21583 {
21584 return qe_invalid;
21585 }
21586
21587
2/2
✓ Branch 0 taken 320 times.
✓ Branch 1 taken 6400 times.
6720 if (!pack_feof(f))
21588 {
21589
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6400 times.
6400 if (!p_mgetl(&section_id,f))
21590 {
21591 return qe_invalid;
21592 }
21593 6400 }
21594
21595 6720 return qe_cancel;
21596 }
21597
21598 11325 return qe_OK;
21599 18045 }
21600
21601 // TODO: this was copied from zc/zasm_utils.cpp
21602 287 static void _zasm_for_every_script(std::function<void(zasm_script*)> fn)
21603 {
21604 extern std::vector<std::shared_ptr<zasm_script>> zasm_scripts;
21605
21606 287 std::vector<zasm_script*> scripts;
21607
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 scripts.reserve(zasm_scripts.size());
21608
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 308020 times.
308307 for (auto& script : zasm_scripts)
21609
3/4
✓ Branch 0 taken 308020 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8685 times.
✓ Branch 3 taken 299335 times.
308020 if (script->valid())
21610
1/2
✓ Branch 0 taken 8685 times.
✗ Branch 1 not taken.
8685 scripts.push_back(script.get());
21611
21612
2/4
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 287 times.
287 std::for_each(scripts.begin(), scripts.end(), fn);
21613 287 }
21614
21615 477 static bool compat_qr_hide_bottom_pixels(const zquestheader& header)
21616 {
21617 // 2.55.9 or newer?
21618
2/2
✓ Branch 0 taken 146 times.
✓ Branch 1 taken 331 times.
477 if (header.compareVer(2, 55, 9) >= 0)
21619 146 return false; // defer to whatever was set
21620
21621 // Replays created in 2.55 for quests prior to 2.55.9 should continue hiding the bottom pixels.
21622
12/18
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 281 times.
✓ Branch 2 taken 281 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 281 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 50 times.
✓ Branch 7 taken 281 times.
✓ Branch 8 taken 50 times.
✓ Branch 9 taken 281 times.
✓ Branch 10 taken 50 times.
✓ Branch 11 taken 281 times.
✓ Branch 12 taken 37 times.
✓ Branch 13 taken 294 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
331 if (replay_is_replaying() && replay_get_meta_str("zc_version_created").starts_with("2.55"))
21623 37 return true;
21624
21625 // Quests prior to 2.55.9 with a scripted subscreen?
21626
2/2
✓ Branch 0 taken 148484 times.
✓ Branch 1 taken 290 times.
148774 for (int i = 0; i < MAXDMAPS; i++)
21627 {
21628 148484 int script = DMaps[i].active_sub_script;
21629
4/6
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 148480 times.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
148484 if (script && dmapscripts[script] && dmapscripts[script]->valid())
21630 4 return true;
21631 148480 }
21632
21633 // Only a couple quests take any time (~7ms) on my intel mac to check all the ZASM... cache those.
21634
1/2
✓ Branch 0 taken 290 times.
✗ Branch 1 not taken.
290 std::string title = header.title;
21635
3/4
✓ Branch 0 taken 290 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 287 times.
290 if (title == "Yuurand: Tales of the Labyrinth")
21636 3 return true;
21637
21638 // Look for ZASM setting values of 167, 168, etc. This is a sign that the script may be drawing something
21639 // near the old "bottom" of the screen, or is attempting to fill the entire screen with a draw command.
21640 // In these cases, the compat rule must be flipped on. As of writing, 72 quests in the PZC database match
21641 // this query: https://gist.github.com/connorjclark/edd12f84c9aac0c924ed328d3f8efcfa
21642 287 bool found = false;
21643
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 287 times.
8972 _zasm_for_every_script([&](auto script){
21644
2/2
✓ Branch 0 taken 3034 times.
✓ Branch 1 taken 5651 times.
8685 if (found) return;
21645
21646
2/2
✓ Branch 0 taken 5619 times.
✓ Branch 1 taken 25105016 times.
25110635 for (const auto& instr : script->zasm)
21647 {
21648
4/4
✓ Branch 0 taken 21971385 times.
✓ Branch 1 taken 3133631 times.
✓ Branch 2 taken 363407 times.
✓ Branch 3 taken 21607978 times.
25105016 if (!(instr.command == SETV || instr.command == PUSHV)) continue;
21649
21650 3497038 int value = instr.arg2;
21651
9/10
✓ Branch 0 taken 3497035 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 3497031 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 3497007 times.
✓ Branch 5 taken 24 times.
✓ Branch 6 taken 3497007 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✓ Branch 9 taken 3497006 times.
3497038 if (value == 167000000 || value == 168000000 || value == 167870000 || value == 167910000 || value == 168130000)
21652 {
21653 32 found = true;
21654 32 break;
21655 }
21656 }
21657 8685 });
21658
21659 287 return found;
21660 477 }
21661
21662 //Internal function for loadquest wrapper
21663 798 static int32_t _lq_int(const char *filename, zquestheader *Header, miscQdata *Misc, zctune *tunes, bool show_progress, byte *skip_flags, byte printmetadata)
21664 {
21665 798 DMapEditorLastMaptileUsed = 0;
21666 798 combosread=false;
21667 798 mapsread=false;
21668 798 fixffcs=false;
21669
21670 798 bool do_clear_scripts = !get_bit(skip_flags,skip_ffscript);
21671
1/2
✓ Branch 0 taken 798 times.
✗ Branch 1 not taken.
798 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
21672 {
21673 set_bit(skip_flags, skip_ffscript, 1);
21674 setZScriptVersion(V_FFSCRIPT);
21675 FFCore.quest_format[vFFScript] = V_FFSCRIPT;
21676 FFCore.quest_format[vLastCompile] = V_FFSCRIPT;
21677 do_clear_scripts = true;
21678 }
21679
1/2
✓ Branch 0 taken 798 times.
✗ Branch 1 not taken.
798 if(loading_tileset_flags & TILESET_CLEARMAPS)
21680 {
21681 set_bit(skip_flags, skip_maps, 1);
21682 }
21683
21684 // show_progress=true;
21685 char tmpfilename[L_tmpnam];
21686 798 temp_name(tmpfilename);
21687 // char percent_done[30];
21688 798 bool catchup=false;
21689 byte tempbyte;
21690 798 word old_map_count=map_count;
21691
21692 798 byte old_quest_rules[QUESTRULES_NEW_SIZE] = {0};
21693 798 byte old_extra_rules[EXTRARULES_SIZE] = {0};
21694 798 byte old_midi_flags[MIDIFLAGS_SIZE] = {0};
21695
21696
2/2
✓ Branch 0 taken 477 times.
✓ Branch 1 taken 321 times.
798 if(get_bit(skip_flags, skip_rules))
21697 {
21698 321 memcpy(old_quest_rules, quest_rules, QUESTRULES_NEW_SIZE);
21699 321 memcpy(old_extra_rules, extra_rules, EXTRARULES_SIZE);
21700 321 }
21701
21702 798 memset(quest_rules, 0, QUESTRULES_NEW_SIZE); //clear here to prevent any kind of carryover -Z
21703 798 unpack_qrs();
21704 // memset(extra_rules, 0, EXTRARULES_SIZE); //clear here to prevent any kind of carryover -Z
21705
21706
2/2
✓ Branch 0 taken 477 times.
✓ Branch 1 taken 321 times.
798 if(get_bit(skip_flags, skip_midis))
21707 {
21708 321 memcpy(old_midi_flags, midi_flags, MIDIFLAGS_SIZE);
21709 321 }
21710
21711
2/2
✓ Branch 0 taken 477 times.
✓ Branch 1 taken 321 times.
798 if (!get_bit(skip_flags, skip_maps))
21712 477 Regions = {};
21713
21714
2/2
✓ Branch 0 taken 321 times.
✓ Branch 1 taken 477 times.
798 if(do_clear_scripts)
21715 {
21716 477 zScript.clear();
21717 477 globalmap.clear();
21718 477 genericmap.clear();
21719 477 ffcmap.clear();
21720 477 itemmap.clear();
21721 477 npcmap.clear();
21722 477 ewpnmap.clear();
21723 477 lwpnmap.clear();
21724 477 playermap.clear();
21725 477 dmapmap.clear();
21726 477 screenmap.clear();
21727 477 itemspritemap.clear();
21728 477 comboscriptmap.clear();
21729 477 subscreenmap.clear();
21730
21731
2/2
✓ Branch 0 taken 243747 times.
✓ Branch 1 taken 477 times.
244224 for(int32_t i=0; i<NUMSCRIPTFFC-1; i++)
21732 {
21733 243747 ffcmap[i].clear();
21734 243747 }
21735
21736 477 globalmap[0].slotname = "Slot 1:";
21737 477 globalmap[0].scriptname = "~Init";
21738 477 globalmap[0].update();
21739
21740
2/2
✓ Branch 0 taken 3339 times.
✓ Branch 1 taken 477 times.
3816 for(int32_t i=1; i<NUMSCRIPTGLOBAL; i++)
21741 {
21742 3339 globalmap[i].clear();
21743 3339 }
21744
21745
2/2
✓ Branch 0 taken 121635 times.
✓ Branch 1 taken 477 times.
122112 for(int32_t i=0; i<NUMSCRIPTITEM-1; i++)
21746 {
21747 121635 itemmap[i].clear();
21748 121635 }
21749
21750 //new script types -- prevent carrying over to a quest that you load after reading them
21751 //e.g., a quest has an npc script, and you make a blank quest, that now believes that it has an npc script, too!
21752
2/2
✓ Branch 0 taken 121635 times.
✓ Branch 1 taken 477 times.
122112 for(int32_t i=0; i<NUMSCRIPTGUYS-1; i++)
21753 {
21754 121635 npcmap[i].clear();
21755 121635 }
21756
2/2
✓ Branch 0 taken 121635 times.
✓ Branch 1 taken 477 times.
122112 for(int32_t i=0; i<NUMSCRIPTWEAPONS-1; i++)
21757 {
21758 121635 lwpnmap[i].clear();
21759 121635 }
21760
2/2
✓ Branch 0 taken 121635 times.
✓ Branch 1 taken 477 times.
122112 for(int32_t i=0; i<NUMSCRIPTWEAPONS-1; i++)
21761 {
21762 121635 ewpnmap[i].clear();
21763 121635 }
21764
2/2
✓ Branch 0 taken 1908 times.
✓ Branch 1 taken 477 times.
2385 for(int32_t i=0; i<NUMSCRIPTHERO-1; i++)
21765 {
21766 1908 playermap[i].clear();
21767 1908 }
21768
2/2
✓ Branch 0 taken 121635 times.
✓ Branch 1 taken 477 times.
122112 for(int32_t i=0; i<NUMSCRIPTSDMAP-1; i++)
21769 {
21770 121635 dmapmap[i].clear();
21771 121635 }
21772
2/2
✓ Branch 0 taken 121635 times.
✓ Branch 1 taken 477 times.
122112 for(int32_t i=0; i<NUMSCRIPTSCREEN-1; i++)
21773 {
21774 121635 screenmap[i].clear();
21775 121635 }
21776
2/2
✓ Branch 0 taken 121635 times.
✓ Branch 1 taken 477 times.
122112 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE-1; i++)
21777 {
21778 121635 itemspritemap[i].clear();
21779 121635 }
21780
2/2
✓ Branch 0 taken 243747 times.
✓ Branch 1 taken 477 times.
244224 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA-1; i++)
21781 {
21782 243747 comboscriptmap[i].clear();
21783 243747 }
21784
2/2
✓ Branch 0 taken 243747 times.
✓ Branch 1 taken 477 times.
244224 for(int32_t i=0; i<NUMSCRIPTSGENERIC-1; i++)
21785 {
21786 243747 genericmap[i].clear();
21787 243747 }
21788
2/2
✓ Branch 0 taken 121635 times.
✓ Branch 1 taken 477 times.
122112 for(int32_t i=0; i<NUMSCRIPTSSUBSCREEN-1; i++)
21789 {
21790 121635 subscreenmap[i].clear();
21791 121635 }
21792
21793 477 reset_scripts();
21794 477 }
21795
21796 798 zquestheader tempheader{};
21797
1/2
✓ Branch 0 taken 798 times.
✗ Branch 1 not taken.
798 tempheader.filename = filename;
21798
1/2
✓ Branch 0 taken 798 times.
✗ Branch 1 not taken.
798 zinfo tempzi;
21799
1/2
✓ Branch 0 taken 798 times.
✗ Branch 1 not taken.
798 tempzi.clear();
21800 798 load_tmp_zi = &tempzi;
21801
21802 // oldquest flag is set when an unencrypted qst file is suspected.
21803 798 bool oldquest = false;
21804 798 int32_t open_error=0;
21805
1/2
✓ Branch 0 taken 798 times.
✗ Branch 1 not taken.
798 PACKFILE *f=open_quest_file(&open_error, filename, show_progress);
21806
21807
1/2
✓ Branch 0 taken 798 times.
✗ Branch 1 not taken.
798 if (!f)
21808 {
21809 ASSERT(open_error != 0);
21810 return open_error;
21811 }
21812 char zinfofilename[2048];
21813
1/2
✓ Branch 0 taken 798 times.
✗ Branch 1 not taken.
798 replace_extension(zinfofilename, filename, "zinfo", 2047);
21814 798 int32_t ret=0;
21815
21816 //header
21817
1/2
✓ Branch 0 taken 798 times.
✗ Branch 1 not taken.
798 box_out("Reading Header...");
21818
1/2
✓ Branch 0 taken 798 times.
✗ Branch 1 not taken.
798 ret=readheader(f, &tempheader, printmetadata);
21819
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 798 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
798 checkstatus(ret);
21820
1/2
✓ Branch 0 taken 798 times.
✗ Branch 1 not taken.
798 box_out("okay.");
21821
1/2
✓ Branch 0 taken 798 times.
✗ Branch 1 not taken.
798 box_eol();
21822
21823
2/2
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 608 times.
798 if(read_zinfo)
21824 {
21825
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 box_out("Reading ZInfo - ");
21826
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 187 times.
✓ Branch 2 taken 190 times.
✗ Branch 3 not taken.
190 box_out(read_ext_zinfo ? "External..." : "Internal...");
21827
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 187 times.
190 if(read_ext_zinfo)
21828 {
21829
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 PACKFILE *inf=pack_fopen_password(zinfofilename, F_READ, "");
21830
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 ret=readzinfo(inf, tempzi, tempheader);
21831
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if(inf) pack_fclose(inf);
21832
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
3 checkstatus(ret);
21833 3 }
21834 else
21835 {
21836
1/2
✓ Branch 0 taken 187 times.
✗ Branch 1 not taken.
187 ret=readzinfo(f, tempzi, tempheader);
21837
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 187 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
187 checkstatus(ret);
21838 }
21839
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 box_out("okay.");
21840
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 box_eol();
21841 190 }
21842
21843
2/2
✓ Branch 0 taken 774 times.
✓ Branch 1 taken 24 times.
798 if(tempheader.zelda_version>=0x193)
21844 {
21845 dword section_id;
21846
21847 //section id
21848
2/4
✓ Branch 0 taken 774 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 774 times.
✗ Branch 3 not taken.
774 if(!p_mgetl(&section_id,f))
21849 {
21850 goto invalid;
21851 }
21852
21853 774 std::set<dword> seen_sections;
21854
21855
3/4
✓ Branch 0 taken 18819 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18045 times.
✓ Branch 3 taken 774 times.
18819 while(!pack_feof(f))
21856 {
21857
2/4
✓ Branch 0 taken 18045 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18045 times.
✗ Branch 3 not taken.
18045 if (seen_sections.contains(section_id))
21858 goto invalid;
21859
1/2
✓ Branch 0 taken 18045 times.
✗ Branch 1 not taken.
18045 seen_sections.insert(section_id);
21860
21861
3/4
✓ Branch 0 taken 18045 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11325 times.
✓ Branch 3 taken 6720 times.
18045 if (int retval = maybe_skip_section(f, section_id, skip_flags); retval != qe_OK)
21862 {
21863
1/2
✓ Branch 0 taken 6720 times.
✗ Branch 1 not taken.
6720 if (retval == qe_cancel)
21864 6720 continue;
21865 checkstatus(retval);
21866 }
21867
21868
24/25
✓ Branch 0 taken 454 times.
✓ Branch 1 taken 454 times.
✓ Branch 2 taken 774 times.
✓ Branch 3 taken 774 times.
✓ Branch 4 taken 454 times.
✓ Branch 5 taken 395 times.
✓ Branch 6 taken 774 times.
✓ Branch 7 taken 454 times.
✓ Branch 8 taken 454 times.
✓ Branch 9 taken 454 times.
✓ Branch 10 taken 454 times.
✓ Branch 11 taken 454 times.
✓ Branch 12 taken 395 times.
✓ Branch 13 taken 395 times.
✓ Branch 14 taken 454 times.
✓ Branch 15 taken 454 times.
✓ Branch 16 taken 395 times.
✓ Branch 17 taken 395 times.
✓ Branch 18 taken 395 times.
✓ Branch 19 taken 395 times.
✓ Branch 20 taken 454 times.
✓ Branch 21 taken 454 times.
✓ Branch 22 taken 395 times.
✓ Branch 23 taken 395 times.
✗ Branch 24 not taken.
11325 switch(section_id)
21869 {
21870 case ID_RULES:
21871
21872 //rules
21873
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 454 times.
454 if(catchup)
21874 {
21875 box_out("found.");
21876 box_eol();
21877 catchup=false;
21878 }
21879
21880
1/2
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
454 box_out("Reading Rules...");
21881
1/2
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
454 ret=readrules(f, &tempheader);
21882
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 454 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
454 checkstatus(ret);
21883
1/2
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
454 box_out("okay.");
21884
1/2
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
454 box_eol();
21885 454 break;
21886
21887 case ID_STRINGS:
21888
21889 //strings
21890
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 454 times.
454 if(catchup)
21891 {
21892 box_out("found.");
21893 box_eol();
21894 catchup=false;
21895 }
21896
21897
1/2
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
454 box_out("Reading Strings...");
21898
1/2
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
454 ret=readstrings(f, &tempheader);
21899
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 454 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
454 checkstatus(ret);
21900
1/2
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
454 box_out("okay.");
21901
1/2
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
454 box_eol();
21902 454 break;
21903
21904 case ID_MISC:
21905
21906 //misc data
21907
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 774 times.
774 if(catchup)
21908 {
21909 box_out("found.");
21910 box_eol();
21911 catchup=false;
21912 }
21913
21914
1/2
✓ Branch 0 taken 774 times.
✗ Branch 1 not taken.
774 box_out("Reading Misc. Data...");
21915
1/2
✓ Branch 0 taken 774 times.
✗ Branch 1 not taken.
774 ret=readmisc(f, &tempheader, Misc);
21916
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 774 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
774 checkstatus(ret);
21917
1/2
✓ Branch 0 taken 774 times.
✗ Branch 1 not taken.
774 box_out("okay.");
21918
1/2
✓ Branch 0 taken 774 times.
✗ Branch 1 not taken.
774 box_eol();
21919 774 break;
21920
21921 case ID_TILES:
21922
21923 //tiles
21924
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 774 times.
774 if(catchup)
21925 {
21926 box_out("found.");
21927 box_eol();
21928 catchup=false;
21929 }
21930
21931
1/2
✓ Branch 0 taken 774 times.
✗ Branch 1 not taken.
774 box_out("Reading Tiles...");
21932
1/2
✓ Branch 0 taken 774 times.
✗ Branch 1 not taken.
774 ret=readtiles(f, newtilebuf, &tempheader, tempheader.zelda_version, tempheader.build, 0, NEWMAXTILES, false);
21933
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 774 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
774 checkstatus(ret);
21934
1/2
✓ Branch 0 taken 774 times.
✗ Branch 1 not taken.
774 box_out("okay.");
21935
1/2
✓ Branch 0 taken 774 times.
✗ Branch 1 not taken.
774 box_eol();
21936 774 break;
21937
21938 case ID_COMBOS:
21939
21940 //combos
21941
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 454 times.
454 if(catchup)
21942 {
21943 box_out("found.");
21944 box_eol();
21945 catchup=false;
21946 }
21947
21948
1/2
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
454 box_out("Reading Combos...");
21949
1/2
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
454 ret=readcombos(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXCOMBOS);
21950 454 combosread=true;
21951
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 454 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
454 checkstatus(ret);
21952
1/2
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
454 box_out("okay.");
21953
1/2
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
454 box_eol();
21954 454 break;
21955
21956 case ID_COMBOALIASES:
21957
21958 //combo aliases
21959
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 395 times.
395 if(catchup)
21960 {
21961 box_out("found.");
21962 box_eol();
21963 catchup=false;
21964 }
21965
21966
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 box_out("Reading Combo Aliases...");
21967
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 ret=readcomboaliases(f, &tempheader, tempheader.zelda_version, tempheader.build);
21968
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 395 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
395 checkstatus(ret);
21969
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 box_out("okay.");
21970
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 box_eol();
21971 395 break;
21972
21973 case ID_CSETS:
21974
21975 //color data
21976
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 774 times.
774 if(catchup)
21977 {
21978 box_out("found.");
21979 box_eol();
21980 catchup=false;
21981 }
21982
21983
1/2
✓ Branch 0 taken 774 times.
✗ Branch 1 not taken.
774 box_out("Reading Color Data...");
21984
1/2
✓ Branch 0 taken 774 times.
✗ Branch 1 not taken.
774 ret=readcolordata(f, Misc, tempheader.zelda_version, tempheader.build, 0, newerpdTOTAL);
21985
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 774 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
774 checkstatus(ret);
21986
1/2
✓ Branch 0 taken 774 times.
✗ Branch 1 not taken.
774 box_out("okay.");
21987
1/2
✓ Branch 0 taken 774 times.
✗ Branch 1 not taken.
774 box_eol();
21988 774 break;
21989
21990 case ID_MAPS:
21991
21992 //maps
21993
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 454 times.
454 if(catchup)
21994 {
21995 box_out("found.");
21996 box_eol();
21997 catchup=false;
21998 }
21999
22000
1/2
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
454 box_out("Reading Maps...");
22001
1/2
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
454 ret=readmaps(f, &tempheader);
22002 454 mapsread=true;
22003
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 454 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
454 checkstatus(ret);
22004
1/2
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
454 box_out("okay.");
22005
1/2
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
454 box_eol();
22006 454 break;
22007
22008 case ID_DMAPS:
22009
22010 //dmaps
22011
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 454 times.
454 if(catchup)
22012 {
22013 box_out("found.");
22014 box_eol();
22015 catchup=false;
22016 }
22017
22018
1/2
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
454 box_out("Reading DMaps...");
22019
1/2
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
454 ret=readdmaps(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXDMAPS);
22020
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 454 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
454 checkstatus(ret);
22021
1/2
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
454 box_out("okay.");
22022
1/2
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
454 box_eol();
22023 454 break;
22024
22025 case ID_DOORS:
22026
22027 //door combo sets
22028
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 454 times.
454 if(catchup)
22029 {
22030 box_out("found.");
22031 box_eol();
22032 catchup=false;
22033 }
22034
22035
1/2
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
454 box_out("Reading Doors...");
22036
1/2
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
454 ret=readdoorcombosets(f, &tempheader);
22037
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 454 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
454 checkstatus(ret);
22038
1/2
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
454 box_out("okay.");
22039
1/2
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
454 box_eol();
22040 454 break;
22041
22042 case ID_ITEMS:
22043
22044 //items
22045
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 454 times.
454 if(catchup)
22046 {
22047 box_out("found.");
22048 box_eol();
22049 catchup=false;
22050 }
22051
22052
1/2
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
454 box_out("Reading Items...");
22053
1/2
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
454 ret=readitems(f, tempheader.zelda_version, tempheader.build);
22054
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 454 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
454 checkstatus(ret);
22055
22056
1/2
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
454 box_out("okay.");
22057
1/2
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
454 box_eol();
22058 454 break;
22059
22060 case ID_WEAPONS:
22061
22062 //weapons
22063
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 454 times.
454 if(catchup)
22064 {
22065 box_out("found.");
22066 box_eol();
22067 catchup=false;
22068 }
22069
22070
1/2
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
454 box_out("Reading Weapons...");
22071
1/2
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
454 ret=readweapons(f, &tempheader);
22072
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 454 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
454 checkstatus(ret);
22073
1/2
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
454 box_out("okay.");
22074
1/2
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
454 box_eol();
22075 454 break;
22076
22077 case ID_COLORS:
22078
22079 //misc. colors
22080
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 395 times.
395 if(catchup)
22081 {
22082 box_out("found.");
22083 box_eol();
22084 catchup=false;
22085 }
22086
22087
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 box_out("Reading Misc. Colors...");
22088
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 ret=readmisccolors(f, &tempheader, Misc);
22089
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 395 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
395 checkstatus(ret);
22090
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 box_out("okay.");
22091
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 box_eol();
22092 395 break;
22093
22094 case ID_ICONS:
22095
22096 //game icons
22097
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 395 times.
395 if(catchup)
22098 {
22099 box_out("found.");
22100 box_eol();
22101 catchup=false;
22102 }
22103
22104
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 box_out("Reading Game Icons...");
22105
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 ret=readgameicons(f, &tempheader, Misc);
22106
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 395 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
395 checkstatus(ret);
22107
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 box_out("okay.");
22108
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 box_eol();
22109 395 break;
22110
22111 case ID_INITDATA:
22112
22113 //initialization data
22114
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 454 times.
454 if(catchup)
22115 {
22116 box_out("found.");
22117 box_eol();
22118 catchup=false;
22119 }
22120
22121
1/2
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
454 box_out("Reading Init. Data...");
22122
1/2
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
454 ret=readinitdata(f, &tempheader);
22123
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 454 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
454 checkstatus(ret);
22124
1/2
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
454 box_out("okay.");
22125
1/2
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
454 box_eol();
22126
22127
2/4
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 454 times.
454 if(!get_bit(skip_flags, skip_subscreens))
22128 {
22129
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 361 times.
454 if(subscr_mode!=ssdtMAX) //not using custom subscreens
22130 {
22131
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 setupsubscreens();
22132
22133
2/2
✓ Branch 0 taken 47616 times.
✓ Branch 1 taken 93 times.
47709 for(int32_t i=0; i<MAXDMAPS; ++i)
22134 {
22135 47616 int32_t type=DMaps[i].type&dmfTYPE;
22136
2/2
✓ Branch 0 taken 1085 times.
✓ Branch 1 taken 46531 times.
47616 DMaps[i].active_subscreen=(type == dmOVERW || type == dmBSOVERW)?0:1;
22137 47616 DMaps[i].passive_subscreen=(get_qr(qr_ENABLEMAGIC))?0:1;
22138 47616 }
22139 93 }
22140 454 }
22141
22142
2/4
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 454 times.
✗ Branch 3 not taken.
454 if(!get_bit(skip_flags, skip_sfx))
22143 {
22144 454 setupsfx();
22145 454 }
22146
22147
2/4
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 454 times.
✗ Branch 3 not taken.
454 if(!get_bit(skip_flags, skip_itemdropsets))
22148 {
22149
1/2
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
454 init_item_drop_sets();
22150 454 }
22151
22152
2/4
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 454 times.
454 if(!get_bit(skip_flags, skip_favorites))
22153 {
22154 454 init_favorites();
22155 454 }
22156
22157 454 break;
22158
22159 case ID_GUYS:
22160
22161 //guys
22162
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 454 times.
454 if(catchup)
22163 {
22164 box_out("found.");
22165 box_eol();
22166 catchup=false;
22167 }
22168
22169
1/2
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
454 box_out("Reading Custom Guy Data...");
22170
1/2
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
454 ret=readguys(f, &tempheader);
22171
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 454 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
454 checkstatus(ret);
22172
1/2
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
454 box_out("okay.");
22173
1/2
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
454 box_eol();
22174 454 break;
22175
22176 case ID_HEROSPRITES:
22177
22178 //hero sprites
22179
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 395 times.
395 if(catchup)
22180 {
22181 box_out("found.");
22182 box_eol();
22183 catchup=false;
22184 }
22185
22186
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 box_out("Reading Custom Hero Sprite Data...");
22187
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 ret=readherosprites(f, &tempheader);
22188
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 395 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
395 checkstatus(ret);
22189
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 box_out("okay.");
22190
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 box_eol();
22191 395 break;
22192
22193 case ID_SUBSCREEN:
22194
22195 //custom subscreens
22196
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 395 times.
395 if(catchup)
22197 {
22198 box_out("found.");
22199 box_eol();
22200 catchup=false;
22201 }
22202
22203
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 box_out("Reading Custom Subscreen Data...");
22204
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 ret=readsubscreens(f);
22205
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 395 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
395 checkstatus(ret);
22206
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 box_out("okay.");
22207
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 box_eol();
22208 395 break;
22209
22210 case ID_FFSCRIPT:
22211
22212 //Freeform combo scripts
22213
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 395 times.
395 if(catchup)
22214 {
22215 box_out("found.");
22216 box_eol();
22217 catchup=false;
22218 }
22219
22220
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 box_out("Reading FF Script Data...");
22221
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 ret=readffscript(f, &tempheader);
22222
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 395 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
395 checkstatus(ret);
22223
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 box_out("okay.");
22224
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 box_eol();
22225 395 break;
22226
22227 case ID_SFX:
22228
22229 //SFX data
22230
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 395 times.
395 if(catchup)
22231 {
22232 box_out("found.");
22233 box_eol();
22234 catchup=false;
22235 }
22236
22237
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 box_out("Reading SFX Data...");
22238
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 ret=readsfx(f, &tempheader);
22239
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 395 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
395 checkstatus(ret);
22240
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 box_out("okay.");
22241
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 box_eol();
22242 395 break;
22243
22244 case ID_MIDIS:
22245
22246 //midis
22247
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 454 times.
454 if(catchup)
22248 {
22249 box_out("found.");
22250 box_eol();
22251 catchup=false;
22252 }
22253
22254
1/2
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
454 box_out("Reading Tunes...");
22255
1/2
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
454 ret=readtunes(f, &tempheader, tunes);
22256
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 454 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
454 checkstatus(ret);
22257
1/2
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
454 box_out("okay.");
22258
1/2
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
454 box_eol();
22259 454 break;
22260
22261 case ID_CHEATS:
22262
22263 //cheat codes
22264
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 454 times.
454 if(catchup)
22265 {
22266 box_out("found.");
22267 box_eol();
22268 catchup=false;
22269 }
22270
22271
1/2
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
454 box_out("Reading Cheat Codes...");
22272
1/2
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
454 ret=readcheatcodes(f, &tempheader);
22273
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 454 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
454 checkstatus(ret);
22274
1/2
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
454 box_out("okay.");
22275
1/2
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
454 box_eol();
22276 454 break;
22277
22278 case ID_ITEMDROPSETS:
22279
22280 //item drop sets
22281
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 395 times.
395 if(catchup)
22282 {
22283 box_out("found.");
22284 box_eol();
22285 catchup=false;
22286 }
22287
22288
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 box_out("Reading Item Drop Sets...");
22289
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 ret=readitemdropsets(f, tempheader.zelda_version);
22290
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 395 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
395 checkstatus(ret);
22291
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 box_out("okay.");
22292
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 box_eol();
22293 395 break;
22294
22295 case ID_FAVORITES:
22296
22297 //favorite combos and combo aliases
22298
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 395 times.
395 if(catchup)
22299 {
22300 box_out("found.");
22301 box_eol();
22302 catchup=false;
22303 }
22304
22305
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 box_out("Reading Favorite Combos...");
22306
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 ret=readfavorites(f, tempheader.zelda_version);
22307
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 395 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
395 checkstatus(ret);
22308
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 box_out("okay.");
22309
1/2
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
395 box_eol();
22310 395 break;
22311
22312 default:
22313 if(!catchup)
22314 {
22315 box_out("Bad token! Searching...");
22316 box_eol();
22317 }
22318
22319 catchup=true;
22320 break;
22321 }
22322
22323
22324
1/2
✓ Branch 0 taken 11325 times.
✗ Branch 1 not taken.
11325 if(catchup)
22325 {
22326 //section id
22327 section_id=(section_id<<8);
22328
22329 if(!p_getc(&tempbyte,f))
22330 {
22331 goto invalid;
22332 }
22333
22334 section_id+=tempbyte;
22335 }
22336
22337 else
22338 {
22339 //section id
22340
3/4
✓ Branch 0 taken 11325 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10871 times.
✓ Branch 3 taken 454 times.
11325 if(!pack_feof(f))
22341 {
22342
2/4
✓ Branch 0 taken 10871 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10871 times.
✗ Branch 3 not taken.
10871 if(!p_mgetl(&section_id,f))
22343 {
22344 goto invalid;
22345 }
22346 10871 }
22347 }
22348 }
22349
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 774 times.
774 }
22350 else
22351 {
22352
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 std::vector<std::tuple<std::string, int32_t, std::function<int32_t()>>> hardcoded_sections = {
22353
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Rules", ID_RULES, [&](){ return readrules(f, &tempheader); }},
22354
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Strings", ID_STRINGS, [&](){ return readstrings(f, &tempheader); }},
22355
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Doors", ID_DOORS, [&](){ return readdoorcombosets(f, &tempheader); }},
22356
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "DMaps", ID_DMAPS, [&](){ return readdmaps(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXDMAPS); }},
22357
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Misc. Data", ID_MISC, [&](){ return readmisc(f, &tempheader, Misc); }},
22358
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Items", ID_ITEMS, [&](){ return readitems(f, tempheader.zelda_version, tempheader.build); }},
22359
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Weapons", ID_WEAPONS, [&](){ return readweapons(f, &tempheader); }},
22360
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Custom Guy Data", ID_GUYS, [&](){ return readguys(f, &tempheader); }},
22361
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Maps", ID_MAPS, [&](){ return readmaps(f, &tempheader); }},
22362
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Combos", ID_COMBOS, [&](){ return readcombos(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXCOMBOS); }},
22363
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Color Data", ID_CSETS, [&](){ return readcolordata(f, Misc, tempheader.zelda_version, tempheader.build, 0, newerpdTOTAL); }},
22364
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Tiles", ID_TILES, [&](){ return readtiles(f, newtilebuf, &tempheader, tempheader.zelda_version, tempheader.build, 0, NEWMAXTILES, false); }},
22365
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Tunes", ID_MIDIS, [&](){ return readtunes(f, &tempheader, tunes); }},
22366
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Cheat Codes", ID_CHEATS, [&](){ return readcheatcodes(f, &tempheader); }},
22367
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Init. Data", ID_INITDATA, [&](){ return readinitdata(f, &tempheader); }},
22368
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Custom Hero Sprite Data", ID_HEROSPRITES, [&](){ return readherosprites2(f, -1); }},
22369
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Up Default Item Drop Sets", ID_ITEMDROPSETS, [&](){ return readitemdropsets(f, -1); }},
22370 };
22371
22372 24 legacy_skip_flags = skip_flags;
22373
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 408 times.
1250 for (auto& [desc, section_id, fn] : hardcoded_sections)
22374 {
22375
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 int section_enum = section_id_to_enum(section_id);
22376
2/4
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 408 times.
✗ Branch 3 not taken.
408 bool skip = section_enum >= 0 && get_bit(skip_flags, section_enum);
22377
2/2
✓ Branch 0 taken 392 times.
✓ Branch 1 taken 16 times.
408 if (skip)
22378 {
22379 // Nothing to read.
22380
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 15 times.
16 if (section_id == ID_RULES)
22381 1 continue;
22382
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 14 times.
15 if (section_id == ID_GUYS)
22383 1 continue;
22384
22385 // Haven't looked at how to skip these, because we don't need to currently: the only
22386 // usage of skip_flags currently is all off except: header and tiles (see `load_imagebuf`).
22387
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 13 times.
14 if (section_id == ID_MIDIS)
22388 1 continue;
22389
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 12 times.
13 if (section_id == ID_CHEATS)
22390 1 continue;
22391
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 11 times.
12 if (section_id == ID_INITDATA)
22392 1 continue;
22393
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 10 times.
11 if (section_id == ID_HEROSPRITES)
22394 1 continue;
22395
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 9 times.
10 if (section_id == ID_ITEMDROPSETS)
22396 1 continue;
22397 9 }
22398
22399 // Would be nice, but old sections mostly did not save section sizes. We could advance by
22400 // a specific amount, but it'd be a lot of work to get it right. So, for old quests, let's just
22401 // read all the sections even if requested to skip some.
22402 // if (int retval = maybe_skip_section(f, section_id, skip_flags); retval != qe_OK)
22403 // {
22404 // if (retval == qe_cancel)
22405 // continue;
22406 // checkstatus(retval);
22407 // }
22408
22409
3/6
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 401 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 401 times.
✗ Branch 5 not taken.
802 box_out(fmt::format("Reading {}...", desc).c_str());
22410
1/2
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
401 ret = fn();
22411
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 401 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
401 checkstatus(ret);
22412
1/2
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
401 box_out("okay.");
22413
1/2
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
401 box_eol();
22414 }
22415 24 legacy_skip_flags = nullptr;
22416
22417
3/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✓ Branch 3 taken 1 times.
24 if(!get_bit(skip_flags, skip_subscreens))
22418 {
22419
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 setupsubscreens();
22420
22421
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 23 times.
11799 for(int32_t i=0; i<MAXDMAPS; ++i)
22422 {
22423 11776 int32_t type=DMaps[i].type&dmfTYPE;
22424
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 11732 times.
11776 DMaps[i].active_subscreen=(type == dmOVERW || type == dmBSOVERW)?0:1;
22425 11776 DMaps[i].passive_subscreen=(get_qr(qr_ENABLEMAGIC))?0:1;
22426 11776 }
22427 23 }
22428
22429
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 box_out("Setting Up Default Sound Effects...");
22430
22431
3/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 23 times.
24 if(!get_bit(skip_flags, skip_sfx))
22432 23 setupsfx();
22433
22434
3/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✓ Branch 3 taken 1 times.
24 if(!get_bit(skip_flags, skip_favorites))
22435 23 init_favorites();
22436
22437
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 box_out("okay.");
22438
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 box_eol();
22439
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
24 }
22440
22441
1/2
✓ Branch 0 taken 798 times.
✗ Branch 1 not taken.
798 init_spritelists();
22442
22443 // check data
22444
1/2
✓ Branch 0 taken 798 times.
✗ Branch 1 not taken.
798 if(f)
22445 {
22446
1/2
✓ Branch 0 taken 798 times.
✗ Branch 1 not taken.
798 pack_fclose(f);
22447 798 }
22448
1/2
✓ Branch 0 taken 798 times.
✗ Branch 1 not taken.
798 clear_quest_tmpfile();
22449
22450
1/2
✓ Branch 0 taken 798 times.
✗ Branch 1 not taken.
798 if(!oldquest)
22451 {
22452
2/4
✓ Branch 0 taken 798 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 798 times.
798 if(exists(tmpfilename))
22453 {
22454 delete_file(tmpfilename);
22455 }
22456 798 }
22457
22458
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 798 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
798 if(fixffcs && combosread && mapsread)
22459 {
22460 for(int32_t i=0; i<map_count; i++)
22461 {
22462 for(int32_t j=0; j<MAPSCRS; j++)
22463 {
22464 int c = TheMaps[(i*MAPSCRS)+j].numFFC();
22465 for(int32_t m=0; m<c; m++)
22466 {
22467 if(combobuf[TheMaps[(i*MAPSCRS)+j].ffcs[m].data].type == cCHANGE)
22468 TheMaps[(i*MAPSCRS)+j].ffcs[m].flags|=ffc_changer;
22469 }
22470 }
22471 }
22472 }
22473
22474
3/4
✓ Branch 0 taken 798 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 477 times.
✓ Branch 3 taken 321 times.
798 if (!get_bit(skip_flags, skip_rules))
22475 {
22476
1/2
✓ Branch 0 taken 477 times.
✗ Branch 1 not taken.
477 bool should_hide = compat_qr_hide_bottom_pixels(tempheader);
22477
1/2
✓ Branch 0 taken 477 times.
✗ Branch 1 not taken.
477 al_trace("Note: qr_HIDE_BOTTOM_8_PIXELS %s via compat rule\n", should_hide ? "enabled" : "disabled");
22478
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 401 times.
477 if (should_hide)
22479
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 set_qr(qr_HIDE_BOTTOM_8_PIXELS, 1);
22480
22481
3/4
✓ Branch 0 taken 350 times.
✓ Branch 1 taken 127 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 350 times.
477 if (FFCore.quest_format[vCompatRule] < 77 && Header->is_z3)
22482 set_qr(qr_LAYER6_STRINGS_OVER_SUBSCREEN, 1);
22483 477 }
22484
22485
7/10
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 734 times.
✓ Branch 2 taken 64 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 63 times.
✓ Branch 5 taken 1 times.
✓ Branch 6 taken 63 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 63 times.
✗ Branch 9 not taken.
798 if(get_qr(qr_CONTFULL_DEP) && !get_bit(skip_flags, skip_rules) && !get_bit(skip_flags, skip_initdata))
22486 {
22487
1/2
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
63 set_qr(qr_CONTFULL_DEP, 0);
22488
1/2
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
63 zinit.flags.set(INIT_FL_CONTPERCENT,true);
22489 63 zinit.cont_heart=100;
22490 63 zinit.counter[crLIFE]=zinit.mcounter[crLIFE];
22491 63 }
22492
22493
1/2
✓ Branch 0 taken 798 times.
✗ Branch 1 not taken.
798 box_out("Done.");
22494
1/2
✓ Branch 0 taken 798 times.
✗ Branch 1 not taken.
798 box_eol();
22495
1/2
✓ Branch 0 taken 798 times.
✗ Branch 1 not taken.
798 box_end(false);
22496
22497
3/4
✓ Branch 0 taken 798 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 478 times.
✓ Branch 3 taken 320 times.
798 if(!get_bit(skip_flags, skip_header))
22498 {
22499
1/2
✓ Branch 0 taken 478 times.
✗ Branch 1 not taken.
478 *Header = tempheader;
22500 478 }
22501
3/4
✓ Branch 0 taken 798 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 477 times.
✓ Branch 3 taken 321 times.
798 if(!get_bit(skip_flags, skip_zinfo))
22502 {
22503
1/2
✓ Branch 0 taken 477 times.
✗ Branch 1 not taken.
477 ZI.copyFrom(tempzi);
22504 477 }
22505
22506
3/4
✓ Branch 0 taken 798 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 477 times.
✓ Branch 3 taken 321 times.
798 if(get_bit(skip_flags, skip_maps))
22507 {
22508 321 map_count=old_map_count;
22509 321 }
22510
22511
3/4
✓ Branch 0 taken 798 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 321 times.
✓ Branch 3 taken 477 times.
798 if(get_bit(skip_flags, skip_rules))
22512 {
22513 321 memcpy(quest_rules, old_quest_rules, QUESTRULES_NEW_SIZE);
22514 321 memcpy(extra_rules, old_extra_rules, EXTRARULES_SIZE);
22515
1/2
✓ Branch 0 taken 321 times.
✗ Branch 1 not taken.
321 unpack_qrs();
22516 321 }
22517
22518
3/4
✓ Branch 0 taken 798 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 321 times.
✓ Branch 3 taken 477 times.
798 if(get_bit(skip_flags, skip_midis))
22519 {
22520 321 memcpy(midi_flags, old_midi_flags, MIDIFLAGS_SIZE);
22521 321 }
22522
22523
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 798 times.
798 if(loading_tileset_flags & TILESET_CLEARMAPS)
22524 {
22525 TheMaps.clear();
22526 TheMaps.resize(MAPSCRS*1);
22527 map_count = 1;
22528 map_autolayers.clear();
22529 map_autolayers.resize(6*1);
22530 }
22531
22532
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 798 times.
798 if(loading_tileset_flags & TILESET_CLEARHEADER)
22533 {
22534 memset(Header->password, 0, sizeof(Header->password));
22535 memset(Header->minver, 0, sizeof(Header->minver));
22536 memset(Header->title, 0, sizeof(Header->title));
22537 memset(Header->author, 0, sizeof(Header->author));
22538 memset(Header->version, 0, sizeof(Header->version));
22539 Header->use_keyfile = 0;
22540 Header->dirty_password = false;
22541 cvs_MD5Context ctx;
22542 cvs_MD5Init(&ctx);
22543 cvs_MD5Update(&ctx, (const uint8_t*)"", 0);
22544 cvs_MD5Final(Header->pwd_hash, &ctx);
22545 }
22546
22547
3/4
✓ Branch 0 taken 798 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 477 times.
✓ Branch 3 taken 321 times.
798 if (!get_bit(skip_flags, skip_maps))
22548 {
22549 // Not needed, so release its memory.
22550
1/2
✓ Branch 0 taken 477 times.
✗ Branch 1 not taken.
477 old_combo_pages = {};
22551 477 }
22552
22553 798 return qe_OK;
22554
22555 invalid:
22556 // TODO: It's too easy to forget to jump to this label, and accidentally leave the file open.
22557 // Should wrap PACKFILE in a std::unique_pointer with a custom deallocator.
22558 box_out("error.");
22559 box_eol();
22560 box_end(true);
22561
22562 pack_fclose(f);
22563
22564 if(!oldquest)
22565 {
22566 if(exists(tmpfilename))
22567 {
22568 delete_file(tmpfilename);
22569 }
22570 }
22571
22572 return qe_invalid;
22573
22574 798 }
22575
22576 static bool _is_loading_quest;
22577
22578 bool is_loading_quest()
22579 {
22580 return _is_loading_quest;
22581 }
22582
22583 320 std::string get_last_loaded_qstpath()
22584 {
22585 320 return last_loaded_qstpath;
22586 }
22587
22588 798 int32_t loadquest(const char *filename, zquestheader *Header, miscQdata *Misc,
22589 zctune *tunes, bool show_progress, byte *skip_flags, byte printmetadata,
22590 bool report, byte qst_num, dword tilesetflags)
22591 {
22592 798 loading_tileset_flags = tilesetflags;
22593 798 const char* basename = get_filename(filename);
22594 798 zapp_reporting_add_breadcrumb("load_quest", basename);
22595 798 zapp_reporting_set_tag("qst.filename", basename);
22596
22597 798 last_loaded_qstpath = filename;
22598 798 loading_qst_name = filename;
22599 798 loading_qst_num = qst_num;
22600 // In CI, builds are cached for replay tests, which can result in their build dates being earlier than what it would be locally.
22601 // So to avoid a more-recently updated .qst file from hitting the "last saved in a newer version" prompt, we disable in CI.
22602
1/2
✓ Branch 0 taken 798 times.
✗ Branch 1 not taken.
798 if (!is_ci())
22603 loadquest_report = report;
22604
22605 798 _is_loading_quest = true;
22606 798 auto start = std::chrono::steady_clock::now();
22607 798 zprint2("Loading qst: %s\n", filename);
22608 798 int32_t ret = _lq_int(filename, Header, Misc, tunes, show_progress, skip_flags, printmetadata);
22609 798 int32_t load_ms = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - start).count();
22610 798 zprint2("Time to load qst: %d ms\n", load_ms);
22611 798 _is_loading_quest = false;
22612
1/2
✓ Branch 0 taken 798 times.
✗ Branch 1 not taken.
798 if (ret)
22613 zprint2("Error: %s\n", qst_error[ret]);
22614
22615
1/2
✓ Branch 0 taken 798 times.
✗ Branch 1 not taken.
798 if(show_progress)
22616 {
22617 if(ret)
22618 {
22619 box_out("-- Error loading quest file! --");
22620 box_out(fmt::format("Error: {}", qst_error[ret]).c_str());
22621 box_end(true);
22622 }
22623 else box_end(false);
22624 }
22625
22626 798 load_tmp_zi = NULL;
22627 798 loading_qst_name = NULL;
22628 798 loadquest_report = false;
22629 798 loading_qst_num = 0;
22630
22631 798 zapp_reporting_set_tag("qst.author", Header->author);
22632 798 zapp_reporting_set_tag("qst.title", Header->title);
22633 798 zapp_reporting_set_tag("qst.zc_version", Header->getVerStr());
22634
22635 798 return ret;
22636 }
22637